git安装,linux环境下

  1. 删除系统自带的git
yum remove git
  1. 去git下载对应安装包 https://github.com/git/git/releases

  2. 安装依赖以及安装

yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

解压   tar -zxvf

进入解压目录  cd git-2.21.0/

编译    make prefix=/usr/local/git all

安装    make prefix=/usr/local/git install
  1. 编辑环境配置文件
vim /etc/profile
# 末尾添加
PATH=$PATH:/usr/local/git/bin
export PATH

#刷新
source /etc/profile

yum remove git

#刷新
source /etc/profile
  1. 查看
git --version
  1. 配置git
全局配置用户名 git config --global user.name "nameVal"

全局配置邮箱 git config --global user.email "[email protected]"

配置编码
 git config --global core.autocrlf false
 git config --global core.quotepath false 
 git config --global gui.encoding utf-8


公钥配置
ssh-keygen -t rsa (ssh-keygen -t rsa -C "[email protected]")
一路回车,不要输入任何密码之类,生成ssh key pair
Your public key has been saved in /root/.ssh/id_rsa.pub
查看公钥
cat ~/.ssh/id_rsa.pub
查看密钥
cat ~/.ssh/id_rsa

你可能感兴趣的:(git安装,linux环境下)