How to Install and Configure Git on Fedora?

Git is one of the popular Distributed Version Control Systems (DVCS) among programmers. It lets you manage the incremental changes you make to your code. We can also easily revert to the earlier version of a code. Multiple developers can work simultaneously on the same project. Team members can see the changes to a project, message associated with the changes, their collaborators, project timeline, progress of the work, etc.

Benefits of Using Git

Git is an open-source tool and is free for anyone to use. Almost all the changes are done locally and there is no need for propagating those changes to any central server as well. A project can be edited locally and can be later saved to a server, in which every contributor can see and track these changes. Unlike centralized VCS, Git does not have a single point of failure.

Since Git has distributed architecture, everyone can get the latest snapshot of the work, as well as the entire repository contents and its history. If for some reason the server goes down, a copy from the client can be used as a backup and restore to the server.

To store and identify objects within its database, Git uses a cryptographic hash function known as the SHA-1 hash. Before storing any data, Git checks summed it and uses this checksum to refer to it.

It is very easy to install and does not require high-end hardware on the client-side. Many online hosting services like GitHub provide services to host your Git project online for remote access. One can get an entire backup of a repository on their local computer. Changes made by a contributor to a repository become its part after a commit operation.

The commit operation makes a snapshot of the current state in the repository or the database. After we have worked on our project locally, we can publish local commits to our remote Git database or repository using the push command.

What Will We Cover?

In this guide, we will see how we can install and configure Git on Fedora 33 OS. We will install Git from the official repository on Fedora, as well as from the source code downloaded from the Git official website. Let’s get started with the Git installation process.

Method 1. Installing Git from Fedora Repositories Using dnf/yum

This is a very simple method of installing Git. You just need to run the commands below:

Step 1. Update the available system packages with the following command:

$ sudo dnf -y update

Step 2. Now install git with the below command:

$ sudo dnf -y install git

After the above command finishes, use the following command to check the installed version of Git:

$ git --version

That’s all! As you can see, Git already comes installed on Fedora 33, but if it is not, you can install it from the above command.

In this case, you want to uninstall Git, simply run the appended command below:

$ sudo dnf  -y remove git

Method 2. Building Git from source code on Fedora

Git can also be installed on Fedora from the available source code on the Git website. To install them from source code, follow the below procedure:

Step 1. Git requires several packages to be installed before we can install it from source code. Run the below command to install these dependencies:

$ sudo dnf install dh-autoreconf curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel

Step 2. Once we have all the required dependencies in place, we can move on to download the source code. Run the following command to download the compressed tarball of Git source code:

$ wget https://www.kernel.org/pub/software/scm/git/git-2.30.1.tar.gz

Alternatively, you can also visit this link and manually download the file to your system. This is shown here:

Step 3. Extract the downloaded tar file with the below command:

$ tar -zxf git-2.30.1.tar.gz

Step 4. Now move to the extracted folder on the command line window:

$ cd git-2.30.1

Step 5. Run the make command:

$ make configure

Step 6. Run the config script:

$ ./configure --prefix=/usr

Step 7. Run the make all command:

$ make all

Step 8. Run the make install command:

$ sudo make install

Now, Git is installed on your system. Check the version from here:

$ git --version

Configuring Git settings on Fedora

After installing Git, we will need to add our username and email address to our Git account. This will enable us to commit our code properly. This information is used by Git with every commit we make.

Note: The Git username is not the same as that for GitHub.

To set these details, run the following commands:

$ git config --global user.name "your-username"
$ git config --global user.email "[email protected]"

Here replace “your-username” with a username of your choice and “[email protected]” with your email id. The global keyword will make this information be used by every change on your system. If you want to use different information for a project, then simply remove the global keyword when you are inside that specific project.

Let’s add a sample username and email as:

User-name = linuxhint
User-email = mail@me.com

Run the following command to check if these settings worked correctly:

$ git config --list

This is shown below:


Congratulations, you have now successfully installed Git on your Fedora OS. If you have followed this tutorial properly, you will have noticed that Method 1 is very straightforward for installing Git. You only need to run a simple command to get the Git on your system. Meanwhile, Method 2 is a long way route for installing Git, and it is recommended only for advanced users and system administrators. The benefit of using this method is that you can get its latest available version. For example, in Method 1, the version of Git installed from the official repository is 2.28.0, whereas in Method 2 we have version 2.30.1.

About the author

Ali Imran Nagori

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn