安裝
當(dāng)前最新版本git?2.15.0唉地,centos默認(rèn)自帶的是1.8.3版本,有可能會(huì)導(dǎo)致執(zhí)行#?go?get?github.com/gin-gonic/gin命令報(bào)錯(cuò)极颓,提示無(wú)法使用https協(xié)議。
盡量安裝最新版本的git狂秘,再重新配置環(huán)境變量者春。
準(zhǔn)備工作
1钱烟、刪除默認(rèn)老版本
centos自帶Git忠售,7.x版本自帶git 1.8.3.1(應(yīng)該是,也可能不是)羊瘩,安裝新版本之前需要使用
#?yum remove git
2尘吗、安裝所需軟件包
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker
# yum install expat-devel
# yum install libcurl-devel
# yum install perl-ExtUtils-MakeMaker package
注意:如果不安裝上面這些軟件睬捶,在編譯git時(shí)會(huì)報(bào)錯(cuò)臀晃,缺少東西徽惋。
下載git
https://www.kernel.org/pub/software/scm/git/
git-2.15.0.tar.gz 這個(gè)包,進(jìn)入/usr/local目錄下
或者
# wget https://www.kernel.org/pub/software/scm/git/git-2.15.0.tar.gz
解壓
# tar xzf git-2.15.0.tar.gz
# cd git-2.15.0
安裝
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
將/usr/local/git/bin目錄下的所有文件復(fù)制到/usr/local/bin目錄下去
環(huán)境變量
# vim /etc/profile
#git ---------------------
export PATH=/usr/local/git/bin:/usr/local/libexec/git-core:$PATH
# source /etc/profile
注意:將/usr/local/libexec/git-core 路徑家到PATH上
# vim /etc/bashrc
export???PATH=/usr/local/ssdb:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/app/go/go1.9/go/bin:/root/bin:/usr/local/git/bin?加上這段
# source /etc/bashrc
# ?vim ~/.bashrc
export ?PATH=$PATH:/usr/local/git/bin:/usr/local/libexec/git-core
# source /etc/bashrc
檢查版本
# git --version
用go試著下載github代碼宦棺,行不行
#?go?get?github.com/gin-gonic/gin
正常的話蹈丸,一會(huì)包的目錄文件就被下載到GOPATH指定的目錄下了
-----??結(jié)束白华!?-----