操作系統:CentOS 7.4
Git版本:git version 2.21.0
官網文檔將安裝路徑選擇在./configure --prefix=/usr 極不推薦這種方法,如果你這樣安裝,日后想卸載極為麻煩,幾乎刪除不干凈。將安裝路徑選擇在--prefix=/usr/local/git 日后想卸載只需刪除這個目錄即可。
#官網下載軟件
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.21.0.tar.gz
1、安裝依賴包
#內網環境需要本地yum源,本地yum源沒有的包自己找一台聯網的CentOS,執行yum install 軟件包名 --downloadonly --downloaddi=/usr/local/src 下載軟件不安裝,獲得軟件包
#yum -y install gcc gcc-c++ autoconf asciidoc xmlto curl-devel expat-devel gettext-devel openssl-devel zlib-devel docbook2X
#ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi //安裝docbook2X后的操作
2、編譯
#安裝先檢查下是否有舊版本的git,有的話卸載rpm -e --nodeps git
#tar -zxvf git-2.21.0.tar.gz
#cd git-2.21.0
#make configure
#./configure --prefix=/usr/local/git
#make all doc info
#make install install-doc install-html install-info
3、配置git
#git config --global user.name "nishihaoren"
#git config --global user.email "ainiyou@163.com"
#useradd git
#passwd git
4、測試,查看git是否能創建倉庫
#配置環境變量
vim /etc/profile
export PATH=$PATH:/usr/local/git/bin
source /etc/profile
#git --version
git version 2.21.0
#mkdir -p /data/project
#chown git:git -R /data/project/
su - git
$git init --bare /data/project
