Method #1 » Install with Yum source :
[[email protected] ~]# sudo yum install git
To view the version number of the installed git:
[[email protected] ~]# git--versiongit version 1.8.3.1
But the GIT version installed in the Yum source is 1.8.3.1, too old.
Method #2 » Download git source, compile and install :
1. Update the installation Source:
[[email protected] ~]# Yum update
2. Install the GIT dependent packages:
[email protected] ~]# Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc Perl-extutils-makema Ker
3. Go to the GIT website to see the latest version of 2.8.1:
https://git-scm.com/download/
4. Download the Git source code and unzip it:
[Email protected] ~]# wget https://github.com/git/git/archive/v2.8.1.zip[[email protected] ~]# unzip v2.8.1.zip[[ Email protected] ~]# CD git-2.8.1
5. Compile and install to the "/usr/local/git" directory:
At this point, use Git--version to view the Git version, and still find the 1.8.3.1 Version. This is because it uses git under "/usr/bin" by default.
[[email protected] ~]# git--versiongit version 1.8.3.1
Then look at the path where Git is located:
[Email protected] git-2.8.1]# Whereis gitgit:/usr/bin/git/usr/share/man/man1/git.1.gz
6. Set Environment variables:
Put the compiled and installed git path into the environment variable, and let it replace git under "/usr/bin". To do this we can modify the "/etc/profile" file (or the/ETC/BASHRC file) and add "Export Path=/usr/local/git/bin: $PATH" to the last line of the file (that is, 77 lines).
[Email protected] ~]# Vim/etc/profile
Save changes:
[Email protected] ~]# Source/etc/profile
Look at the version number of git again 2.8.1:
[[email protected] ~]# git--versiongit version 2.8.1
CentOS Install git