This guide is for installing the most recent version of Git on CentOS 7 server. The git variant accessible on CentOS 7 repo is the old, Git 1.x. However, if you need the most recent version of Git, i.e. Git version 2.x, utilize this manual for installing it on Centos/RHEL. Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency by tracking changes in any set of files. It is usually used for coordinating work among programmers collaboratively developing source code during software development.. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems).
Please follow below steps to install the latest version of Git 2.x on CentOS/RHEL.
1. Find the latest version of Git installed with the below command:
sudo git --version git version 1.x.x.x
2. Remove previous git versions installed in the server.
sudo yum -y remove git git-*
3. Add End Point CentOS 7 repo
sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
4. Install Git 2.x using the below command
sudo yum install git Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: asi-fs-n.contabo.net Excluding mirror: mirror.de.leaseweb.net Excluding mirror: mirror.nl.leaseweb.net * epel: mirror.23m.com * extras: ftp.antilo.de * remi-php74: mirror.23m.com * remi-safe: mirror.23m.com Excluding mirror: mirror.fra10.de.leaseweb.net * updates: asi-fs-n.contabo.net endpoint | 2.9 kB 00:00:00 endpoint/7/x86_64/primary_db | 656 kB 00:00:01 Resolving Dependencies --> Running transaction check ---> Package git.x86_64 0:1.8.3.1-23.el7_8 will be updated --> Processing Dependency: git = 1.8.3.1-23.el7_8 for package: perl-Git-1.8.3.1-23.el7_8.noarch ---> Package git.x86_64 0:2.38.1-1.ep7 will be an update --> Processing Dependency: git-core-doc = 2.38.1-1.ep7 for package: git-2.38.1-1.ep7.x86_64 --> Processing Dependency: git-core = 2.38.1-1.ep7 for package: git-2.38.1-1.ep7.x86_64 --> Running transaction check ---> Package git-core.x86_64 0:2.38.1-1.ep7 will be installed --> Processing Dependency: libpcre2-8.so.0()(64bit) for package: git-core-2.38.1-1.ep7.x86_64 ---> Package git-core-doc.noarch 0:2.38.1-1.ep7 will be installed ---> Package perl-Git.noarch 0:1.8.3.1-23.el7_8 will be updated ---> Package perl-Git.noarch 0:2.38.1-1.ep7 will be an update --> Running transaction check ---> Package pcre2.x86_64 0:10.23-2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================= Package Arch Version Repository Size ========================================================================================= Installing for dependencies: git-core x86_64 2.38.1-1.ep7 endpoint 9.6 M git-core-doc noarch 2.38.1-1.ep7 endpoint 2.9 M pcre2 x86_64 10.23-2.el7 base 201 k Updating for dependencies: perl-Git noarch 2.38.1-1.ep7 endpoint 39 k Transaction Summary ========================================================================================= Install ( 3 Dependent packages) Upgrade 1 Package (+1 Dependent package) Total download size: 13 M Is this ok [y/d/N]:
Next, enter y to accept installation and proceed
Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/5): git-2.38.1-1.ep7.x86_64.rpm | 64 kB 00:00:00 (2/5): pcre2-10.23-2.el7.x86_64.rpm | 201 kB 00:00:00 (3/5): git-core-2.38.1-1.ep7.x86_64.rpm | 9.6 MB 00:00:02 (4/5): git-core-doc-2.38.1-1.ep7.noarch.rpm | 2.9 MB 00:00:01 (5/5): perl-Git-2.38.1-1.ep7.noarch.rpm | 39 kB 00:00:00 ----------------------------------------------------------------------------------------- Total 5.7 MB/s | 13 MB 00:00:02 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pcre2-10.23-2.el7.x86_64 1/7 Installing : git-core-2.38.1-1.ep7.x86_64 2/7 Installing : git-core-doc-2.38.1-1.ep7.noarch 3/7 Updating : perl-Git-2.38.1-1.ep7.noarch 4/7 Updating : git-2.38.1-1.ep7.x86_64 5/7 Cleanup : git-1.8.3.1-23.el7_8.x86_64 6/7 Cleanup : perl-Git-1.8.3.1-23.el7_8.noarch 7/7 Verifying : git-core-doc-2.38.1-1.ep7.noarch 1/7 Verifying : git-core-2.38.1-1.ep7.x86_64 2/7 Verifying : perl-Git-2.38.1-1.ep7.noarch 3/7 Verifying : pcre2-10.23-2.el7.x86_64 4/7 Verifying : git-2.38.1-1.ep7.x86_64 5/7 Verifying : git-1.8.3.1-23.el7_8.x86_64 6/7 Verifying : perl-Git-1.8.3.1-23.el7_8.noarch 7/7 Dependency Installed: git-core.x86_64 0:2.38.1-1.ep7 git-core-doc.noarch 0:2.38.1-1.ep7 pcre2.x86_64 0:10.23-2.el7 Updated: git.x86_64 0:2.38.1-1.ep7 Dependency Updated: perl-Git.noarch 0:2.38.1-1.ep7 Complete!
Git 2.x is now installed, verify the installation using the below command.
sudo git --version git version 2.38.1
So, confirmed that the current installed Git version is 2.x.x.
You can read other GIT tutorials in the below links:
1. Git Commands for developers and sysadmins
2. Install the git credential-oskeychain