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:
Step 2. Now install git with the below command:
After the above command finishes, use the following command to check the installed version of Git:
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:
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:
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:
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:
Step 4. Now move to the extracted folder on the command line window:
Step 5. Run the make command:
Step 6. Run the config script:
Step 7. Run the make all command:
Step 8. Run the make install command:
Now, Git is installed on your system. Check the version from here:
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.email "your@emailID"
Here replace “your-username” with a username of your choice and “your@emailID” 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-email = mail@me.com
Run the following command to check if these settings worked correctly:
This is shown below:
Conclusion
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.