How to Install Git and Setup Git Account in RHEL, CentOS and Fedora

For newbies, Git is a free and open source, fast and distributed version control system (VCS), which by design is based on speed, efficient performance and data integrity to support small-scale to extensive software development projects.

Git is a software repository that allows you to keep a track of your software changes, revert to previous version and create another versions of files and directories.

Git is written in C, with a mix of Perl and a variety of shell scripts, it’s primarily intended to run on the Linux kernel and has a number of remarkable features as listed below:

  1. Easy to learn
  2. It is fast and most of its operations are carried out locally, in addition, this offers it a tremendous speed on centralized systems that need to communicate with remote servers.
  3. Highly efficient
  4. Supports data integrity checks
  5. Enables cheap local branching
  6. Offers a convenient staging area
  7. It also maintains multiple work-flows together with many others

In this how-to guide, we shall move through the necessary steps of installing Git on CentOS/RHEL 7/6 and Fedora 20-24 Linux distributions along with how to configure Git so that you can start participating right away..

Install Git Using Yum

We shall install Git from the system default repositories, and make sure that your system is up-to-date with the latest version of packages by running the YUM package manager update command below:

# yum update

Next, install Git by typing the following command:

# yum install git 

After git successfully installed, you can issue the following command to display the version of Git installed:

# git --version 
Check Git Installed Version

Check Git Installed Version

Important: Installing Git from default repositories will give you older version. If you looking to have a most recent version of Git, consider compiling from source using following instructions.

Install Git from Source

Before you begin, first you need to install required software dependencies from the default repositories, along with the utilities that needed to build a binary from source:

# yum groupinstall "Development Tools"
# yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel

After you have installed required software dependencies, go to the official Git release page and grab the latest version and compile it from source using following series of command:

# wget https://github.com/git/git/archive/v2.10.1.tar.gz -O git.tar.gz
# tar -zxf git.tar.gz
# cd git-2.10.1/
# make configure
# ./configure --prefix=/usr/local
# make install
# git --version
Check Installed Git Version

Check Installed Git Version

Suggested Read: 11 Best Git Clients and Git Repository Viewers for Linux

Set Up Git Account in Linux

In this section, we shall cover how to set up a Git account with correct user information such as name and email address to avoid any commit errors, and the git config command is used to do that.

Important: Make sure to replace username with the actual name for the Git user to be created and used on your system.

You can start by creating a Git user with the useradd command as below, where the -m flag used to create the user’s home directory under /home and -s specifies the user’s default shell.

# useradd -m -s /bin/bash username 
# passwd username

Now, add the new user to the wheel group to enable the account to use the sudo command:

# usermod username -aG wheel 
Create Git User Account

Create Git User Account

Then configure Git with the new user as follows:

# su username 
$ sudo git config --global user.name "Your Name"
$ sudo git config --global user.email "[email protected]"

Now verify Git configuration using following command.

$ sudo git config --list 

If there are no errors with the configurations, you should be able to view an output with the following details:

user.name=username
user.email= [email protected]
Setup Git Account in Linux

Setup Git Account in Linux

Suggested Read: Create and Share Your Own Projects on GITHub Repository

Conclusion

In this simple tutorial, we have looked at how to install Git on your Linux system as well as configuring it. I believe the instructions are easy to follow, however, to get in touch with us for any questions or suggestions you can make use of the reaction section below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

4 Responses

  1. Kyle Walker says:

    And as an aside, Git isn’t in any of RHEL Desktop Repos. I was doing a proof of concept for RHEL 7 Desktop and you cannot install git from the repos directly. Just wanted to put that here for anyone else doing the same thing.

  2. Hi!

    If you want a local/remote Git hosting solution, use an Affero GPL one: https://rocketgit.com
    It is free of charge for hosting both public and private repos.

    It also have a bug tracker and Continuous Integration and deployment features.
    VM images for KVM/VMWare/VirtualBox can be found at https://rocketgit.com/op/download/vm
    You can have you Git hosting solution, on your servers, in less than 2 minutes!
    Enjoy!

    Full disclosure: I am the author.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.