How to Install Git on Fedora 39, 38 Linux

For those aiming to install Git on Fedora Linux, understanding the significance of this tool is paramount. Git, a premier open-source version control system, is indispensable for developers and project managers, ensuring streamlined tracking and management of project changes. Whether you’re handling a modest project or orchestrating a massive one, Git’s capabilities are tailored to meet diverse needs. Let’s explore the process and benefits of integrating Git into your Fedora Linux environment.

Why Choose Git on Fedora Linux:

  • Efficient Version Control: Git’s robust version control mechanisms allow for meticulous tracking of project modifications, ensuring that every change is accounted for.
  • Collaborative Utility: Git facilitates seamless collaboration, enabling multiple contributors to work on a project simultaneously without overwriting each other’s changes.
  • Rapid Performance: Git is designed for speed. Whether committing changes, merging branches, or cloning repositories, Git ensures swift and smooth operations.
  • Data Integrity: With its content-addressable filesystem, Git guarantees the integrity of your project data. Every file and commit is checksummed, ensuring data consistency and corruption prevention.
  • Backup and Restore: Git’s distributed nature means every contributor’s local repository is a full-fledged backup. This redundancy ensures data safety and easy restoration.

With a grasp of Git’s pivotal role in project management, the next step is its integration. The subsequent sections will guide you on how to install or upgrade Git on Fedora Linux using the command line terminal. Additionally, we’ll touch upon foundational Git CLI commands to kickstart your version control journey.

Update Fedora System Packages Before Git Installation

First, update your system to ensure all existing packages are up to date.

sudo dnf upgrade --refresh

Install Git on Fedora via DNF or Source

Install Git on Fedora via DNF

Fedora, by default, maintains an up-to-date version of Git. This makes the installation process straightforward. To install Git using the DNF package manager, execute the following command:

sudo dnf install git

Install Git on Fedora via Source

For those who require a specific version of Git not available through the DNF package manager or wish to install Git with custom configurations, compiling from the source code is the way to go.

Start by visiting the official Git website’s release page. This will allow you to identify the latest stable version or pinpoint a specific version you’re after. Once you’ve chosen your desired version, you can download its source code using the wget command in the terminal:

wget https://github.com/git/git/archive/refs/tags/v2.42.0.tar.gz

Please do not copy the above command, its an example only. Git releases new versions frequently, so checking the official website regularly is important to keep your Git installation up-to-date.

After downloading, extract the source code with the tar command:

tar -xzf v2.42.0.tar.gz

Then, change your directory to the one containing the extracted source:

cd git-2.42.0

Before diving into the compilation, installing the necessary development tools is essential. These tools ensure the presence of most required dependencies:

sudo dnf groupinstall "Development Tools"

However, the standard development tools package might not include a few dependencies. To install these, use:

sudo dnf install libcurl-devel expat-devel

With the prerequisites in place, you can now configure the script. Execute the make command:

make prefix=/usr/local all

To finalize the installation of Git, run:

sudo make prefix=/usr/local install

To verify the successful installation and check the version of Git you’ve installed, use:

git --version
Screenshot showcasing the completed Git installation using the source install method on Fedora Linux.Pin
A visual demonstration of Git’s interface on Fedora Linux post successful source installation.

Basic Git Commands on Fedora

The following parts will cover some typical setups and commands used daily by users of GIT. This is not the complete list, GIT has a vast amount of commands and configurations, but newer users may find some of the following examples helpful. I would check out the Git documentation for more information in the long term for users seeking more advanced requirement options or usage.

GIT Add user on Fedora

After installation, you must set up standard settings such as names and e-mails, mainly around git commit messages. This is pretty straightforward, 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 be fake if you prefer.

git config --global user.email "YOUR EMAIL"

GIT Create Directory on Fedora

First, create a directory for users who want to make a new directory strictly for GIT.

mkdir example-directory -p

Next, navigate to the directory.

cd example-directory -p

The next task is to use the initialization command, and this will create a hidden .git directory to store the configuration, history, and so on.

git init

You will see a terminal output stating the status of the directory being initialized, and you can additionally see the content using the following command.

ls -a .git

Print GIT CONFIG Details on Fedora

To confirm GIT config users and details, 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.

cat ~/.gitconfig

The sudo command with the git config command will set two separate user names and e-mails.

Store GIT Credentials on Fedora

You can enable the credential helper cache for users who want to store authorization details using the following.

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, if 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 the expiry for 5 hours.

git config --global credential.helper "cache --timeout=18000"

After 5 hours, the credentials will be deleted, securing your GIT.

Check Directory GIT Status on Fedora

To view the status of a GIT repository, you can use the following git status command:

git status

While the above command helps with giving a status of the GIT, you can additionally list all git commands and sub.

Connect Remote GIT Repository on Fedora

For users that need to work with GIT remotes to sync and download/upload changes, you will need to link the GIT. This can be done using the git remote command:

git remote add origin remote-repository-link

Commit GIT Changes on Fedora

When you have completed changes in your GIT directory and want to SYNC it to push to the remote repository, use the following git commit command:

git commit -m "git message changelog"

Note the -m “git message change” is the message that appears in the changelog.

Push GIT Changes on Fedora

To push or send changes to the remote repository to SYNC in both versions, use the following git push command:

git push origin master

Pull GIT Changes on Fedora

Alternatively, to pull or get changes from the remote repository to SYNC in both versions, use the following git pull command:

git pull origin master

Additional Commands & Tips

How to Update Git

For updates to GIT, they will be included with your standard system packages as you installed git-core with the DNF package manager. Use the following command to update and upgrade.

sudo dnf update --refresh

Additional Git Commands on Fedora

How to Remove Git From Fedora

Whether for system maintenance, version management, or other reasons, there might be times when you need to uninstall Git from your Fedora system. The removal process will depend on how you initially installed Git. Here’s a guide to help you through both scenarios.

DNF Git Remove Method Command for Fedora

If you installed Git using the DNF package manager, uninstalling it is straightforward. Execute the following command:

sudo dnf remove git

This command will prompt the DNF package manager to locate and uninstall Git and its associated files from your Fedora system.

Compiled Git Version Remove Method for Fedora

If you’ve installed Git from the source, the removal process requires manual intervention since no direct uninstaller is provided. Here’s how you can proceed:

Locate the Installation Directory: If you followed the standard installation process, Git’s binaries are likely in /usr/local/bin. You can verify this with the terminal which command:

which git

Remove the Binaries: Once you’ve identified the installation directory, you can manually remove the Git binaries:

sudo rm -f /usr/local/bin/git
sudo rm -f /usr/local/bin/git-*

Remove Associated Directories: Additionally, you might want to remove other directories associated with Git:

sudo rm -rf /usr/local/libexec/git-core

After completing the above steps for either method, Git should be successfully removed from your Fedora system. To verify the removal, you can run:

git --version

If Git has been removed, this command should return an error indicating that Git is not found.

Conclusion

In conclusion, our exploration of Git installation on Fedora Linux has provided a comprehensive understanding of the available methods. We delved into the convenience of utilizing Fedora’s default Git version, which, given Fedora’s nature as an upstream release, suffices for a majority of users. However, for those seeking the cutting-edge or a specific version, we also discussed downloading and installing Git from the source. Whichever route you choose, it’s evident that Fedora offers the flexibility to cater to diverse Git requirements, ensuring every user can harness the power of this essential version control system efficiently.

Leave a Comment


Your Mastodon Instance
Share to...