1. 程式人生 > >Linux下Git安裝及配置較詳細

Linux下Git安裝及配置較詳細

1.下載git原始碼

目前最新版本下載地址:https://mirrors.edge.kernel.org/pub/software/scm/git/

--下載 :wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz

2.解壓安裝包

--解壓:tar -zxvf git-2.9.5.tar.gz

--移直目標檔案:mv /root/git-2.9.5  /usr/git-2.9.5(使用Xftp操作也可)

--進入解壓包目錄 cd usr/git-2.9.5

3.安裝

--指定安裝目錄 ./configure  --prefix=/usr/git

./configure報錯

[[email protected] git-2.9.5]# ./configure --prefix=/home/Git configure: Setting lib to 'lib' (the default) configure: Will try -pthread then -lpthread to enable POSIX Threads. configure: CHECKS for site configuration checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/home/tools/git-2.9.5': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details

執行報錯中看出gcc,cc,cl.exe為no。gcc是linux的c語言編譯器,說明我的機器中沒有安裝這些編譯器。

分別安裝以下gcc,gcc-c++,安裝成功之後執行一下git安裝命令:

[[email protected] git-2.9.5] #  yum install gcc   

[[email protected] git-2.9.5] #  yum install gcc-c++

[[email protected] git-2.9.5] #  ./configure --prefix=/usr/git

--安裝 make && make install

make命令報錯

[[email protected] git-2.9.5]# make && make install * new build flags CC credential-store.o In file included from credential-store.c:1:0: cache.h:40:18: 致命錯誤:zlib.h:沒有那個檔案或目錄 #include <zlib.h> ^ 編譯中斷。 make: *** [credential-store.o] 錯誤 1

缺少zlib的標頭檔案,開發包沒裝。安裝zlib

[[email protected] git-2.9.5]# yum install zlib

[[email protected] git-2.9.5]# yum install zlib-devel

[[email protected] git-2.9.5]# yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

[[email protected] git-2.9.5]# make && make install

 

執行後繼續報錯,錯誤資訊: 

MSGFMT po/bg.msg make[1]: * [po/bg.msg] Error 127

解決方式:

yum install tcl build-essential tk gettext

再次執行安裝:

[[email protected] git-2.9.5]# make && make install

 則安裝成功。

4.檢查git是否安裝完成

進入指定的安裝目錄,檢視git版本

[[email protected] bin]# cd /usr/Git/bin

[[email protected] bin]# ./git --version

git version 2.9.5

5.配置環境變數:

vi /etc/profile

編輯配置檔案,在最後追加下面的字串,指定bin目錄地址

$PATH://usr/git/bin

修改完成之後,執行命令,生效配置檔案

source /etc/profile

檢查是否配置成功,可切換路徑到其他目錄,執行 git --version。返回git版本則表示環境變數配置完成。

 

在安裝過程中,查到的資料連結如下: 

https://www.cnblogs.com/afan/p/9282526.html

https://blog.csdn.net/a924420593/article/details/79859377  --解決Git 報錯 po/bg.msg make[1]: *** [po/bg.msg] 錯誤 127

https://www.cnblogs.com/afan/p/9282526.html

https://www.cnblogs.com/qiutianyou/p/9501498.html

https://blog.csdn.net/zhezhebie/article/details/78035979--解決git fatal: Unable to find remote helper for 'https'