Installing the latest version of Git on Fedora takes a little extra work since Fedora doesn’t update the Git version in the package manger very often. Fedora attempts to be extra stable so it doesn’t provide the latest and greatest version of Git in the repositories. It takes a little extra work to download and compile Git yourself, but the process is simple and straightforward. Novice Linux users should be able to complete these instructions in a couple minutes.
Install Git on Fedora Through the Package Manager
First let’s do it the easy way. If you’re ok using an older version of Git (potentially way-older), you can easily install Git through the package manager on Fedora and be done with it.
sudo yum install git
Given the frequency that Fedora updates Git in the repositories, you’re going to quickly find yourself out of date with the Git project. The next best option is to download the Git code yourself, compile and install it directly.
Install Git on Fedora by Compiling the Latest Code
Remove the existing version of git if it is installed via the package manager:
sudo yum remove git
If you’ve previously installed, a custom version of Git on Fedora and are here to update your version again, you should remove your current version of Git by deleting the git folder inside /usr/src. It might look something like /usr/src/git-2.5.1.
Next, install some preliminary packages so we can compile Git:
sudo yum install nano curl-devel expat-devel gettext-devel openssl-devel zlib-devel sudo yum install gcc perl-ExtUtils-MakeMaker
Head over to https://www.kernel.org/pub/software/scm/git/ to find a list of git tarballs that are available to download. The code below shows how to download the 2.8.1 version of Git to your home directory.
cd ~ wget https://www.kernel.org/pub/software/scm/git/git-2.8.1.tar.gz
Move the tarball you just downloaded to the /usr/src directory.
sudo mv git-2.8.1.tar.gz /usr/src
Extract the tarball then delete it.
1 2 3
cd /usr/src sudo tar xzf git-2.8.1.tar.gz sudo rm git-2.8.1.tar.gz
Compile and install Git:
1 2 3
cd git-2.8.1 sudo make prefix=/usr/local/git all sudo make prefix=/usr/local/git install
Become root and add a line to the end of your /etc/bashrc.
sudo su echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
Open the above file by executing nano /etc/bashrc and make sure the line was successfully added and it only appears one time. Next, go back to your account and reload the /etc/bashrc file:
exit source /etc/bashrc
Verify the new version of git has been installed:
We hope you found this article useful. If you see any mistakes, missing features or ways to improve it, please let us know in the comments below so we can update its contents. If you're willing to link to us, we would sincerely appreciate it!