1、查看是否已安裝git:git --version
如想安裝新版本先卸載:yum
remove git
(注:用yum
install git安裝仍然是老版本)
正式安裝
1享潜、安裝編譯git時(shí)需要的包
yum -y install gcc openssl openssl-devel curlcurl-devel unzip perl perl-devel expat expat-devel zlib zlib-devel asciidocxmlto gettext-devel openssh-clients
2困鸥、Windows下載安裝包,通過winSCP上傳到虛擬機(jī)中的app/software目錄下
3剑按、解壓git安裝包:
cd /app/software
tar -zxvf git-2.13.1.tar.gz
4疾就、創(chuàng)建git安裝路徑:mkdir
-p /usr/local/git
5、移動(dòng)解壓出來的包到安裝路徑下mv
/app/software/git-2.13.1 /usr/local/git
6艺蝴、切換至安裝包解壓后的文件夾:cd
/usr/local/git/git-2.13.1(這步很重要)
7猬腰、編譯:make prefix=/usr/local/git
all
8、安裝:make
prefix=/usr/local/git install
(注:步驟7和8可以合并操作猜敢,make
prefix=/usr/local/git make && make install)
9姑荷、配置環(huán)境變量:vi /etc/bashrc
export GIT_HOME=/usr/local/git
export PATH=$GIT_HOME/bin:$PATH
(也可以只維護(hù)一個(gè)盒延,export PATH=/usr/local/git/bin:$PATH)
10、使環(huán)境變量生效:source /etc/bashrc
11鼠冕、查看版本:git --version(2個(gè)橫杠添寺,不同于java、python)