Git is a mature, actively maintained open source project initially developed in 2005 by Linus Torvalds, the famous Linux operating system kernel creator. Git is designed for developers that need a pretty straightforward version control system. Most software is collaborative efforts and sometimes can have hundreds of people with commits working on software development projects. It is essential to track these commits customarily done in branches in most projects before being merged into the master for release. It is easy to review and track down any incorrect commits and revert, leading to a much easier development if anything goes wrong.
In the following tutorial, you will learn how to install Git on your Fedora 35 operating system with various methods.
Table of Contents
- Recommended OS: Fedora Linux 35
- User account: A user account with sudo or root access.
Update Operating System
Update your Fedora operating system to make sure all existing packages are up to date:
sudo dnf upgrade --refresh -y
The tutorial will be using the sudo command and assuming you have sudo status.
To verify sudo status on your account:
Example output showing sudo status:
[joshua@fedora ~]$ sudo whoami root
To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Fedora.
To use the root account, use the following command with the root password to log in.
Method 1. Install Git with DNF (Recommended)
Git is available in the default Fedora repository, installed using the DNF package manager. By default, this should be installed on your Fedora 35 system.
To re-install Git, use the following command:
sudo dnf install git -y
Once installed, verify the installation:
git version 2.33.1
Method 2. Compile & Install Git from Source
The tutorial has covered how to install a stable repository version using the DNF package manager. However, for those wanting the absolute latest Git version, it’s recommended to always install from the source.
As with unstable, you will need to make sure any security issues are monitored; with the source, you can quickly re-compile any urgent updates making this the better option for anyone needing to use the latest Git.
To begin with, install the Git dependencies as follows:
sudo dnf install gettext-devel curl-devel expat-devel openssl-devel perl-CPAN perl-devel zlib-devel unzip cmake gcc make wget -y
Once the dependencies are installed, visit the release page to find the master zip archive or the latest stable release from Git.
At the time of writing the guide, 3.34.00-RC1 is the latest release.
Use the wget command as below:
Use the wget command to get the latest development version (master):
wget https://github.com/git/git/archive/refs/heads/master.zip -O git.zip
Note, do not use this version unless as it will be unstable and possibly contain bugs.
Next, Unzip which archive you downloaded:
Now you will need to navigate to the directory using the CD command:
You now need to run the following make commands to install git:
make prefix=/usr/local all
sudo make prefix=/usr/local install
Now that you have installed Git from the source, verify the installation and build:
git version 2.34.0-rc1
Remember, you will need to re-download and re-compile for future updates. Do not forget to keep checking the GIT release page.
How to Configure Git
After installation, you will need to set up standard settings such as names and e-mails, mainly around git commit messages. This is pretty straight forward as the tutorial will explain below.
The first step is to provide your name that will be set Globally:
git config --global user.name "YOUR NAME"
Next, select your e-mail; this can fake if you prefer:
git config --global user.email "YOUR EMAIL"
To confirm these have been added, use the config –list command:
git config --list
Unless specified, Git stores details in the ~/.gitconfig file. You can review what is currently stored by using the cat command:
Note, using the sudo command with the git config command will set two separate user names and e-mails.
You can store this information for quicker access in the future; note this is for dedicated servers being run by 1 or 2 people that are trustworthy as the information isn’t stored securely or encrypted and is just in text form, so any users that have access to the server can easily read this.
git config --global credential.helper cache
If you must use credential helper, it is advised to cache only for a limited time for increased security. For example, you will be working today using Git for 1 to 4 hours but won’t be touching it for maybe a few weeks, then set expiry for 5 hours:
git config --global credential.helper "cache --timeout=18000"
After 5 hours, the credentials will be deleted. This secures your GIT.
Further customization can be learned by visiting the documentation. The above settings should set the default of what most users will need.
Comments and Conclusion
Git is a fantastic piece of software for software developers and sysadmins. Web server owners can track changes on specific directories when developing your servers or website, and the ability to quickly revert should not be looked over. Git is not the most accessible software to work. However, it works well for what it is designed for.