This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.
Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.
See Instead: This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.
The following DigitalOcean tutorial may be of immediate interest, as it outlines installing Git on a CentOS 7 server:
Git is an open source, distributed version control system developed by Linus Torvalds, the creator of Linux. It features trivial branching and merging, the ability to manage multiple remote repositories for a single project, and truly distributed development.
Although git is wonderful at managing large, complex projects with perhaps hundreds or thousands of contributors, it can also work extremely well for small projects with one person or a small team. This flexibility makes it a great choice for implementing version and source control for software projects of any size.
In this article, we will cover how to install git on a CentOS 6.4 server using
yum, the CentOS package manager. We will then show how to install git from source in case you would like to benefit from the latest improvements.
As is the case with most Linux distributions, git is available from CentOS’s default repositories. We can install the package maintainer’s most recent version with:
sudo yum install git
You will have to type “y” to confirm the installation. Afterwards, git will be installed and ready to use.
If you want the most recent version of git, you are better off downloading the most recent version from source and compiling from there.
The version in the CentOS repositories as of this writing is 1.7.1, while the latest version of git is 1.8.4, which is a significant difference.
First, we need to download compilation tools for CentOS using the following command:
sudo yum groupinstall "Development Tools"
This will install the make tools and compilers needed to transform source code into binary executables.
Once this is complete, we will need to install some extra dependencies that git needs either to build or run:
sudo yum install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel
Once these are installed, you can obtain the latest version of git from the code hosted on github.com:
wget -O git.zip https://github.com/git/git/archive/master.zip
Unzip the archive and change into the project directory:
We can figure the package, build the executables and documentation, and then install it with the following set of commands:
make all doc
sudo make install install-doc install-html
To update git at a later date, you can actually use git! Clone the git repository on github into a new directory and then build and install it, as before:
git clone git://github.com/git/git
When you commit changes with git, it embeds your name and email address into the commit message in order to easily track changes.
If we do not configure this information ourselves, git may try to guess these values (probably incorrectly) by using your Linux username and hostname.
Give git the values you wish to use for these parameters with these commands:
The configuration changes will be stored in a file in your home directory. You can see them with a normal text editor:
name = Your Name Here
email = firstname.lastname@example.org
You can also view this information by querying git itself for the current configuration settings:
git config --list
user.name=Your Name Here
As mentioned earlier, if you forget to set up these steps, git may try to fill in these values automatically:
[master 0d9d21d] initial project version
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email email@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
Depending on your version of git, it may fail entirely:
<pre> git commit </pre> <pre> *** Please tell me who you are.
to set your account’s default identity. Omit --global to set the identity only in this repository.
fatal: empty ident name (for <demo@example.(none)>) not allowed </pre>
As you can see, git is very good about telling you exactly what you should be doing.
You now have git installed and can start learning some basic usage. We have a few tutorials that may be good to look at:
Git is a tool that becomes immediately useful with a basic understanding, and continues to offer advantages as your knowledge grows.
<div class=“author”>By Justin Ellingwood</div>
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.