Git is fast becoming the defacto code versioning system used by professional developers.
Developed by Linux creator Linus Torvalds, Git is an open source, distributed version control system.
Being distributed gives it many advantages over it’s older rival SVN, being able to commit and create branches locally without access to a central server, to name just one.
It scales from massive projects with hundreds of developers right down to a one-man shop, perfectly.
As most deployments are now on VPS or cloud hybrids, they may not always come with Git fully installed.
Here’s how to install Git on a CentOS 6 machine., first using the easy method, then manually to get the latest version of Git.
Installing Git Using Yum
[codelet]sudo yum install git[/codelet]
This does require
If you get the following error “Requires:
[codelet]sudo yum install perl[/codelet]
Installing Git Manually from Source Code
This is a little bit more hands on but will give you greater control and the latest version of Git.
The CentOS repository as of this article contains Git v.184.108.40.206 whereas the latest version of Git is 220.127.116.11 which is quite a difference.
If you’re using Git
Before installing Git we have to install the Development Tools from the CentOS repository which includes the compiler used to compile the source code.
We also need to install some other dependencies to get the Git source to compile and run.
[codelet]sudo yum install
Ok – now we’re ready to get the latest zip of Git from github.com and compile it.
Create and move into a tmp folder in your home drive
[codelet]cd ~md tmp[/codelet]
[codelet]wget -O git.zip https://github.com/git/git/archive/master.zip[/codelet]
With the master.zip file downloaded, unzip it and move into the folder git-master.
[codelet]unzip git.zipcd git-master[/codelet]
Now we can make the configuration file, give it the parameters it needs and compile the source into a binary file we can run along with related docs.
[codelet]make all doc[/codelet]
[codelet]sudo make install install-doc install-html[/codelet]
The compilation will take a few minutes to run through to completion.
When finished run Git at the command line to make sure it’s installed properly.
[codelet]git version 1.8.5.GIT[/codelet]
Once installed you can simply keep Git up-to-date by using itself to clone the github.com repo into a new folder then run the build and install process again. How handy!
[codelet]git clone git://github.com/git/git[/codelet]
There is one last step to follow and that’s to configure Git with your details.
When committing files to a git repo it stores your name and email along with the commit information so that changes can be tracked back to a single developer.
These need to be set up otherwise Git my try and use your VPS username and host email for commits.
[codelet]git config –global user.name “Enter Your Name Here”[/codelet]
[codelet]git config –global user.email “[email protected]”[/codelet]
The information is stored in a .gitconfig file in your home folder.
You can edit this information at any time.
Or you can check the information directly from Git
[codelet]git config –list[/codelet]
Congratulations – you now have Git working on your CentOS 6 VPS.
Git is a
Explore and have fun.