- 查看当前
git
版本
[root@iZuf68cdepp2gl3ujapkhzZ ~]# git --version
git version 1.8.3.1
查看最新版git
- 移除旧版本git(如果有)
[root@iZuf68cdepp2gl3ujapkhzZ laravel]# yum remove git
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-13.el7 will be erased
--> Processing Dependency: git = 1.8.3.1-13.el7 for package: perl-Git-1.8.3.1-13.el7.noarch
--> Processing Dependency: git for package: gettext-devel-0.19.8.1-2.el7.x86_64
--> Running transaction check
---> Package gettext-devel.x86_64 0:0.19.8.1-2.el7 will be erased
---> Package perl-Git.noarch 0:1.8.3.1-13.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================================================================================
Removing:
git x86_64 1.8.3.1-13.el7 @base 22 M
Removing for dependencies:
gettext-devel x86_64 0.19.8.1-2.el7 @base 1.4 M
perl-Git noarch 1.8.3.1-13.el7 @base 57 k
Transaction Summary
============================================================================================================================================================================================================================================
Remove 1 Package (+2 Dependent packages)
Installed size: 24 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : gettext-devel-0.19.8.1-2.el7.x86_64 1/3
Erasing : perl-Git-1.8.3.1-13.el7.noarch 2/3
Erasing : git-1.8.3.1-13.el7.x86_64 3/3
Verifying : git-1.8.3.1-13.el7.x86_64 1/3
Verifying : gettext-devel-0.19.8.1-2.el7.x86_64 2/3
Verifying : perl-Git-1.8.3.1-13.el7.noarch 3/3
Removed:
git.x86_64 0:1.8.3.1-13.el7
Dependency Removed:
gettext-devel.x86_64 0:0.19.8.1-2.el7 perl-Git.noarch 0:1.8.3.1-13.el7
Complete!
- 下载
git
安装包安装
[root@iZuf68cdepp2gl3ujapkhzZ ~]# wget https://Github.com/Git/Git/archive/v2.11.0.tar.gz
--2018-05-29 15:20:14-- https://github.com/Git/Git/archive/v2.11.0.tar.gz
Resolving github.com (github.com)... 13.250.177.223, 13.229.188.59, 52.74.223.119
Connecting to github.com (github.com)|13.250.177.223|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/git/git/tar.gz/v2.11.0 [following]
--2018-05-29 15:20:15-- https://codeload.github.com/git/git/tar.gz/v2.11.0
Resolving codeload.github.com (codeload.github.com)... 13.250.162.133, 13.229.189.0, 54.251.140.56
Connecting to codeload.github.com (codeload.github.com)|13.250.162.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: 鈥榲2.11.0.tar.gz鈥
[ <=> ] 6,231,904 84.5KB/s in 2m 0s
2018-05-29 15:22:18 (50.5 KB/s) - 鈥榲2.11.0.tar.gz鈥saved [6231904]
解压压缩文件。
[root@iZuf68cdepp2gl3ujapkhzZ ~]# tar -zxvf v2.11.0.tar.gz
只是解压完了,还要设为能全局访问。
[root@iZuf68cdepp2gl3ujapkhzZ ~]# cd git-2.11.0/
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]# make configure
GIT_VERSION = 2.11.0
GEN configure
#如果报错 /bin/sh: autoconf: command not found:
#安装libtool即可: yum install install autoconf automake libtool
#正常会打印: GEN configure
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]# ./configure --prefix=/usr/local/git --with-iconv --with-curl --with-expat=/usr/local/lib
#./configure --prefix=/usr/local/git --with-iconv =/usr/local/lib(建议优先尝试后者)或者
#./configure --prefix=/usr/local/git --with-iconv --with-curl --with-expat=/usr/local/lib(如果没有安装libiconv请自行安装)
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]#make && make install
#如果报错: cache.h:40:18: fatal error:zlib.h:No such file or directory
#安装zlib: yum install zlib、yum install zlib-devel
#如果报错: make[1]: *** [perl.mak] Error 2
#安装: yum install perl-ExtUtils-MakeMaker package
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]# source /etc/bashrc
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]# git --version
git version 2.11.0
安装完毕。
- QAQ
编译git时报错: zlib.h: No such file or directory
缺少zlib的头文件,开发包没装,
yum install zlib (系统默认已经装上)
yum install zlib-devel
git clone时候提示fatal: Unable to find remote helper for 'https'
yum install libcurl-devel
然后按照上诉步骤重新安装编译git即可
5.git
初始化参数配置
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]# git config --global user.name "你的用户名"
[root@iZuf68cdepp2gl3ujapkhzZ git-2.11.0]# git config --global user.email "你的邮箱"
http://blog.csdn.net/u010887744/article/details/53957613