Git has released 2.29 version on Oct 19, 2020. Git is a free and open-source distributed version control system. It is designed to handle small to very large projects with speed and efficiency. To read more details and changes about Git 2.29 read release notes. If you are using a Git repository for your development, then you must require a git client on your system and you need to install git client on your workstation system.
This tutorial will help you to install git 2.29 on CentOS/RHEL 7/6 and Fedora 32/31/30/29/28/27 operating systems using the source code. For beginners visit Git console on your browser and learn Git uses and command-line tips.
Step 1 – Prerequisites
Before installing Git from source code, make sure you have already installed the required packages on your system. If not use the following command to install the required packages.
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker
Step 2 – Install Git on CentOS & Fedora
Download latest Git source code from kernel git or simply use following command to download Git 2.29.0.
cd /usr/src
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.29.0.tar.gz
tar xzf git-2.29.0.tar.gz
After downloading and extracting Git source code, Use the following command to compile the source code.
cd git-2.29.0
make prefix=
/usr/local/git allmake prefix=
/usr/local/git install
Step 3 – Setup Environment
After installation of git client. Now you just need to set binary in the system environment. Set the PATH variable with newly installed git binary in /etc/bashrc by executing below command. Also, reload the changes in the current environment.
echo 'export PATH=
/usr/local/git/bin :$PATH' >> /etc/bashrcsource /etc/bashrc
After completing the steps. Let’s use the following command to check the current git version.
git --version
git version 2.25.0
Git has been successfully installed on your system. Next, you can visit our Git tutorials section to read more about.
Conclusion
Its good to have your software’s up to date. In this tutorial, you have instructions to install Latest git on CentOS 7/6 and Fedora Linux systems.
26 Comments
Worked for me on Redhat Linux 6.10. Thanks!
with git 2.25 too:
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker
mkdir /usr/src/git
cd /usr/src/git
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.0.tar.gz
tar xzf git-2.25.0.tar.gz
cd git-2.25.0/
make prefix=/usr/local/git all
make prefix=/usr/local/git install
[[email protected] git-2.25.0]# /usr/local/git/bin/git –version
git version 2.25.0
[[email protected] git-2.25.0]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.10 (Santiago)
In step 3
echo “export PATH=/usr/local/git/bin:$PATH” >> /etc/bashrc
should be replaced by
echo ‘export PATH=/usr/local/git/bin:$PATH’ >> /etc/bashrc
with single quotes, otherwise you add your current path to /etc/bashrc instead of updating $PATH
Thanks Carl, We have updated tutorial accordingly.
just use command below:
sudo yum install git
Thank you, your tutorial is greet! Helpful!
I am unable to proceed with the first commands itself – pre requisites for git. i am getting the following error;
[[email protected] yum.repos.d]$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[sudo] password for mtr_kvankayala:
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
No package curl-devel available.
No package expat-devel available.
No package gettext-devel available.
No package openssl-devel available.
No package zlib-devel available.
Error: Nothing to do
Is there any solution for this?
Followed the steps exactly.. It worked fine on Fedora 11.
Unfortunately Compling from source and and installing that way messes up your whole system and I wish people would stop posting these kinds of articles thinking they know what they are doing.
This is 1990s system admin and its not a good idea to do this anymore pretty much ever.
So many people have articles showing how to do this, but its nearly the worst thing you can do. Especially if the system is a server.
It is Especially bad if you do that with multiple programs.
Why?
There is a good chance that during a yum update some time later that your system will break a dependency that you compiled the source with.
It works until its broken, which is one month later when you do a package update, or two months later. Its a ticking time bomb you never know when it will happen but rest assured it will happen eventually.
On top of this very few packages actually have proper removal feature so uninstalling them is a major pain.
You have binaries all over your system that were installed by source balls and you don’t have any rpm -qif like feature to figure out which source ball installed them.
THe proper way is to build an RPM from the source:
https://www.thegeekstuff.com/2015/02/rpm-build-package-example/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%253A+TheGeekStuff+
And then install it via yum or rpm.
Then you can remove it easily and and you will be notified when an upgrade will break your dependencies..
Please write an article on that and replace this one with it so a bunch of people out there don’t break your system like my junior admin did following your article.
Isaac, I understand your concern but please bring the complaint to the responsible party i.e. RedHat for not caring enough to provide a recent version of git out-of-the-box. Your message reads awfully close to shooting the messenger as-is.
Your absolutely right. this method will not work eventually. my build system broke this we from a yum update from followoing instructions like this. system has been down for days. These tutorials are not the right way to do it.
I couldn’t pass the step “make prefix=/usr/local/git all” . keep asking me need this need that packages. tried to get still unable to get git on my machine. thanks for your help.
I installed git on red hat 7 according to your tutorial. but it leaded to a fatal error. after I installed git successfully, my p4 (perforce command line) could’t connect to the server, and then I tried to restart the virtual machine to see if it could be modified, but I cannot restart the virtual machine because it became black screen completely in the startup process. then I test install git and restart machine in a clean machine, it produced same result. So I have no way to start my original machine. I am so sad.
Thank you.
Worked perfectly for 2.7.4 as well.
Thanks for the toturial! I had one minor issue when running git with sudo. I solved it by creating a symlink to a directory which is already defined in PATH. Then you can skip the steps to update the existing PATH.
sudo ln -s /usr/local/git/bin/git /usr/local/bin/git
Also see https://unix.stackexchange.com/questions/209381/adding-a-new-directory-to-path-vs-a-symlink-for-directory-already-in-path
Thanks for the tutorial, I have followed the same steps and Installed version 2.9.2 on RHEL.
But the Version shows as 1.8.3.1, any thoughts on how to fix it?
Please provide me the output of below commands:
which git
echo $PATH
I did exactly what TOM B suggested with one more change.
Either remove old version of git:
$ sudo yum remove git
or prepend new git directory to path, instead of appending:
# echo “export PATH=/usr/local/git/bin:$PATH” >> /etc/bashrc
If you find yourself in need of sudoing the echo above, use this form:
$ echo ‘export PATH=/usr/local/git/bin:$PATH’ | sudo tee –append /etc/bashrc > /dev/null
Tested on CentOS 7 and Git 2.8.0 and works like a charm.
This steps damage my centos 6.7. I can`t start my system now.
I had the same problem with RHEL; thankfully reverted back to old snapshot of the virtual machine(vm ware).This happens as previous PATH goes for toss;needs to be very careful while playing with system files.
I’d already installed git via yum only to realise it was a very old version (1.7) which installs in `/usr/bin` and has precedence in the PATH if you run
“`
echo “export PATH=$PATH:/usr/local/git/bin” >> /etc/bashrc
“`
The alternative is either running:
“`
echo “export PATH=/usr/local/git/bin:$PATH” >> /etc/bashrc
“`
So that the version of git in /usr/local/git/bin has priority or running
“`
yum remove git
“`
So that only 2.7 is installed.
I didn’t install gettext-devel and it worked.
Update: gettext-devel is used to create documentation, so it’s probably a good idea to install it.
Because of this, I prefer using this:
echo “export PATH=/usr/local/git/bin:$PATH” >> /etc/bashrc
how to deploy for a few users to use it?
Thank you, this tutorial worked out great.
Thanks… Short and perfect steps…