This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
The lines that the user needs to enter or customize will be in red in this tutorial! The rest should mostly be copy-and-pastable.
Git is a distributed version control system released to the public in 2005. The program allows for non-linear development of projects, and can handle large amounts of data effectively by storing it on the local server. This tutorial will cover two ways to install Git.
Installing Git with apt-get is a quick and easy process. The program installs on the virtual private server with one command:
sudo apt-get install git-core
After it finishes downloading, you will have Git installed and ready to use.
If you are eager to download the most recent version of Git, it is generally a good idea to install it from the source.
Quickly run apt-get update to make sure that you download the most recent packages to your VPS.
sudo apt-get update
Prior to installing Git itself, download all of the required dependancies:
sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
Once they are installed, you can download the latest version of Git from the google code page.
After it downloads, untar the file and switch into that directory:
tar -zxf git-188.8.131.52.tar.gz
If you want to do a global install, install it once as yourself and once as root, using the sudo prefix:
make prefix=/usr/local all sudo make prefix=/usr/local install
If you need to update Git in the future, you can use Git itself to do it.
git clone git://git.kernel.org/pub/scm/git/git.git
After Git is installed, whether from apt-get or from the source, you need to copy your username and email in the gitconfig file. You can access this file at ~/.gitconfig.
Opening it following a fresh Git install would reveal a completely blank page:
sudo nano ~/.gitconfig
You can use the follow commands to add in the required information.
git config --global user.name "NewUser" git config --global user.email firstname.lastname@example.org
You can see all of your settings with this command:
git config --list
If you avoid putting in your username and email, git will later attempt to fill it in for you, and you may end up with a message like this:
[master 0d9d21d] initial project version Committer: root
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
This tutorial covered how to install Git on your virtual private server. Stay tuned for a second tutorial on Git Basics.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.Sign up now
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Good tutorial… Very useful… easy to use, well explained… :-)
The power of linux-warrior-travelers is to be alert, to get maximum effect from minimal impulse because of such great tuts 8) Thanx, Etel!
fatal: bad config file line 1 in /home/nikhil/.gitconfig
getting this problem help me
Another way to get the latest version of git in Ubuntu is using the Ubuntu Git Maintainers PPA:
If you don’t have the add-apt-repository utility
sudo apt-get install python-software-properties
Register the PPA
sudo add-apt-repository ppa:git-core/ppa
update package index
sudo apt-get update
If you don’t have git installed yet
sudo install git
sudo apt-get upgrade
it is very use full…thank you…
to fix the syntax error , you have to put this [user] before name and email properties, like this : [user] name = nafia email = firstname.lastname@example.org
I solved it myself
Hi how can i connect with sourcetree to my git bare repo?
used to get this msg:
The program ‘git’ is currently not installed. To run ‘git’ please ask your administrator to install the package ‘git’
here is how you fix it
[code] sudo dpkg --configure -a [/code]
if you still having proble installing git
I used the first method at the top, it seemed the most idiot(me) proof and all the commands worked (I think) they threw no errors anyway but afterwards in putty all three it has “user name” and it has “email” both those lines fully typed out then under both of them but when I type “git config --list” nothing happens I just get another new line to enter stuff on no errors being thrown, what am I dong wrong, please say someone watches these comments everything has gone perfect till here, love your guys’ beginner tutorials, I couldn’t even start my first droplet without the tuts lol…