Centos6.5用yum命令安裝的自帶git版本是1.7.1的,在使用中會因爲版本太低報錯,使用下面的方法正常升級。git
一、安裝編譯所需依賴庫shell
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMakerbash
二、卸載Centos自帶的git1.7.1ssh
經過git –version查看系統帶的版本,Cento6.5應該自帶的是git版本是1.7.1curl
# yum remove giturl
三、下載新版本git並編譯安裝日誌
# wget https://www.kernel.org/pub/software/scm/git/git-2.9.0.tar.gzcode
# tar zxvf git-2.9.0.tar.gzssl
# cd git-2.9.0rem
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc
四、安裝完成查看版本號
# git --version
git version 2.9.0
五、遇到遠程clone始終須要輸入密碼的狀況,排查了2天,
最後查到服務端日誌 /var/log/secure ,
裏面有這種提示:
Mar 9 16:41:22 iZ23pzb4tg2Z sshd[3001]: User git not allowed because shell /usr/bin/git-shell does not exist Mar 9 16:41:22 iZ23pzb4tg2Z sshd[3002]: input_userauth_request: invalid user git Mar 9 16:44:16 iZ23pzb4tg2Z sshd[3011]: User git not allowed because shell /usr/bin/git-shell does not exist Mar 9 16:44:16 iZ23pzb4tg2Z sshd[3012]: input_userauth_request: invalid user git
最後從新設置 /etc/passwd裏面git-shell路徑就行了
六、生成SSH Key
設置用戶名和email
git config --global user.name "zhucaixiang"
git config --global user.email "xxxx@qq.com"
生成ssh key
ssh-keygen -t rsa -C "xxxx@qq.com"
注意下輸出的信息,能夠看出.pub在哪一個路徑
複製裏面的信息,粘貼到git的ssh key 中