以centos6.8为例
获取git-v2.8.0.tar.gz包
安装git依赖
sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils- MakeMaker
解压git-v2.8.0.tar.gz包
sudo tar -zxvf git-v2.8.0.tar.gz
进入git目录
cd git-2.8.0/
执行 sudo make prefix=/usr/local/git all
sudo make prefix=/usr/local/git install
配置环境
sudo vim /etc/profile
在PATH中加入/usr/local/git/bin
source /etc/profile
测试安装
git --version
出现以下内容说明安装成功
git version 2.8.0
配置用户名,邮箱
git config --global user.name ""
git config --global user.email ""
配置ssh
ssh-keygen -t rsa -C "邮箱"
ssh-add ~/.ssh/id_rsa
(若出现Could not open a connection to your authentication agent.
需要执行eval `ssh-agent`(符号点是数字1左边的小点)
再执行一边ssh-add ~/.ssh/id_rsa)
获取公钥即可
cat ~/.ssh/id_rsa.pub