Git is a powerful and widely used distributed version control system (VCS) essential for managing code projects. It allows you to track changes, collaborate effectively, and revert to previous versions if necessary. This guide will walk you through the straightforward process of installing Git on your Fedora Linux system.

Advertisement

Prerequisites

  • A Fedora Linux system with an active internet connection.
  • Basic understanding of using the terminal.
  • Administrative privileges (sudo access) on your system.

Method 1: Installing Git from Default Repository

This method is the easiest way to get Git up and running on your Fedora system. The official Fedora repositories contain stable versions of Git, and they ensure compatibility with the system.

  1. Open a Terminal Window::Press Ctrl + Alt + T or search for “Terminal” in your applications menu to launch a terminal window.
  2. Update Package Lists (Optional but Recommended): It’s a good practice to ensure your system has the latest package information:
    sudo dnf update 
    
  3. Install Git: Use the dnf package manager, specifically designed for Fedora and related distributions, to install Git:
    sudo dnf install git git-all 
    

    The git-all package includes additional Git utilities for a more comprehensive Git experience.

  4. Verify Installation: Check if Git is installed correctly by running the following command:
    git --version 
    

    A successful installation will display the installed Git version.

Method 2: Installing Git from Latest Source Code

For those who need the latest features or fixes from the Git software, compiling from source might be the preferred route. This method is a bit more involved but offers the most up-to-date version of Git.

  1. Install Required Dependencies: To compile Git from source, several development tools and libraries are needed. Install them using:
    sudo dnf groupinstall "Development Tools" 
    sudo dnf install zlib-devel perl-CPAN gettext 
    
  2. Download the Latest Git Source Code: Navigate to the official Git website or repository to find the link to the latest source code. Alternatively, you can use wget or curl to fetch it directly. Here’s how to do it with wget:
    wget https://github.com/git/git/archive/refs/tags/v2.44.0.tar.gz 
    

    Replace [2.44.0] with the desired version number.

  3. Extract the Tarball and Navigate to the Directory:
    tar -xvzf v2.44.0.tar.gz 
    cd git-2.44.0 
    
  4. Compile and Install: Execute the following commands in order:
    ./configure --prefix=/usr 
    make 
    sudo make install 
    
  5. Verify Installation: Check if Git is installed correctly by running the following command:
    git --version 
    

    This command should display the version you just installed, confirming that the installation process was successful.

Conclusion

Congratulations! You’ve successfully installed Git on your Fedora Linux system. Now you’re ready to start using Git for version control in your development projects.

Here are some resources for further exploration:

By following these steps and exploring the provided resources, you’ll be well on your way to mastering Git and streamlining your development workflow on Fedora Linux.

Share.

15 Comments

  1. This has worked fine.

    But does it changes the bash_profile in user’s home directory ?
    what does command “source /etc/bashrc” exactly does. ?

    Also, in case if we need to revert the installed git, then what the procedure for it ?.

  2. Thanks man, this really helped me on CentOS 6.9. I was struggling to update it from 1.7.1 to some newer version, and this article helps me to do it in few minutes!

  3. Hi,

    I was looking for a way how to bring latest Git to REHL 6 and there’s another, much easier way. Use Rackspace’s IUS repositories, they have rpms for latest Git version.

    Regards,
    P.

  4. I did the installation, everything went successfully. But now when I do git –version, it shows version 1.7.1 instead of version 2.0.5

  5. I am getting below error… Can you help out.. I am trying this on RHEL7

    [root@CTSC00541480801 git-2.5.0]# make prefix=/opt/git all
    CC credential-store.o
    In file included from credential-store.c:1:0:
    cache.h:21:18: fatal error: zlib.h: No such file or directory
    #include
    ^
    compilation terminated.
    make: *** [credential-store.o] Error 1
    [root@CTSC00541480801 git-2.5.0]

    • Not having the zlib.h file most likely means that you didn’t install the zlib-devel package. Try doing that yum install zlib-devel step again.

  6. This worked well, thanks!

    Had to ensure I exported the Git path though. In .bash_profile or other startup dotfile:

    export PATH=$PATH:/usr/local/git/bin

Exit mobile version