转:https://www.cnblogs.com/lijinhui/p/6901220.html
1.删除已有的git
yum remove git
2.安装git依赖包
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
3.下载git源码
地址:https://github.com/git/git/releases
wget https://github.com/git/git/archive/v2.14.0.tar.gz
4.源码安装
解压缩
tar -zxvf v2.14.0.tar.gz
cd git-2.14.0/
mkdir /usr/local/git/
make prefix=/usr/local/git/ all
make prefix=/usr/local/git/ install
5.配置环境变量
vi /etc/profile
export PATH=/usr/local/git/bin:$PATH
source /etc/profile
6.全局配置git
配置用户名和密码
git config --global user.name "username"
git config --global user.email "email"
提交检出均不转换换行符
git config --global core.autocrlf false
#中文乱码
git config --global core.quotepath off
git config --global gui.encoding utf-8
7.生成ssh公钥
ssh-keygen -t rsa -C "邮箱"
ssh-add ~/.ssh/id_rsa
可能报错Could not open a connection to your authentication agent
执行
ssh-agent bash
eval 'ssh-agent'
重新执行
ssh-add ~/.ssh/id_rsa
查看公钥
cat ~/.ssh/id_rsa.pub
复制公钥到码云上配置