資源:git-2.9.5 ,多版本下載地址,這個頁面的下載可能很慢,可以試下這裏
1.解壓文件
tar -zxvf git-2.9.5.tar.gz
2.進入git-2.9.5,使用configure,生成Makefile文件
./configure --prefix=/usr/local/git295
常用配置項
--prefix= :指定安裝的路徑
--sysconfdir= :指定配置文件目錄
--enable-feature :啓用某個特性
--disable-fecture :禁用特性
--with-function :啓用某功能
--with-php-config=/usr/local/php/bin/php-config :例如安裝php擴展時啓用php配置文件
--without-function :禁用某功能
3.執行make,從Makefile中讀取指令,將源碼編譯成二進制目標文件,並存放在當前目錄下,如果之前有執行過make,存留了舊的目標文件*.o,要先使用 make clean 進行清除再使用make
make
4.執行make install 進行安裝
make install
5.設置全局可直接使用git命令:通過軟連接將安裝目錄下的bin/git引用到/usr/local/bin下
ln -s /usr/local/git295/bin/git /usr/local/bin/git
6.首次使用git commit時,會提示 git config --global user.email "[email protected]" git config --global user.name “Your Name” ,要求設置用戶信息(用戶信息值可以自定義設置,沒有要求),爲了避免覆蓋機器上其他用戶的設置,不要用全局設置,去掉–global 配置項即可
git config user.email "[email protected]"
git config user.name "user1@test1"
操作完後,查看到.git/config配置文件中被自動添加了[user]值
[user]
email = [email protected]
name = user1@test1