git Installation for Ubuntu 14.04
Introduction to gitAn indispensable tool in modern software development, git is a control system. The Version control systems will let you keep track of a software in the source level. You can also track changes or revert it to previous stages and possibly branch to make various versions of files and directories. A few of the most used version control systems is ‘git’, a distributed version control system. A lot of projects will maintain their files in a git repository; sites such as GitHub and BitBucket have done shared and contributed to this code which is simple and valuable. In this tutorial we will teach you how to install git on an Ubuntu 14.04 VPS instance. Then, how to install the software in two different ways; each way with its own benefits. This tutorial will require you to be signed as a non-root user.
How To Install git with AptThus far, using Ubuntu will be your easiest way to get git installed and ready to use; using Ubuntu’s default repositories is also by far the fastest method, although the version you have might be older than the newest one. If you want the latest release, consider following the steps to compile git from source. You can use the ‘apt’ package management tool in order to update your local package index. Then, you can download and install the program.
$ sudo apt-get update $ sudo apt-get install gitThis will download and install git to your system. Now you must complete the configuration steps which we will cover in the ‘setup’ part of the article; this means that you may skip to that part now.
How To Install Git from SourceA more flexible method for installing Git is by compiling the software from source. It will take longer and will not be maintained through your package manager. It should allow you to download the latest release and then it will add some control over the options you include if you desire to customize. Before you start, you will want to install the software that git depends on. This is all available in the default repositories; that way you can update your local package index and, afterwards, install the packages with the following commands.
$ sudo apt-get update $ sudo apt-get install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzipOnce you have installed your necessary dependencies, you can acquire the version of git that you desire; you can do so by visiting the official git project page on Github. The version you will see after you arrive at the project’s page is the branch which is actively being committed to. If you want the latest stable release, you must go change the branch to the latest non ‘rc’ tag using the button along the left side of the project header. Now, on the right side of the page, right-click the ‘Download ZIP’ button and choose the option which is similar to ‘Copy Link Address’. Back on your Ubuntu 14.04 VPS, you can write wget and paste the address which you have copied. Note that the URL you have copied may be different than shown here.
Now unzip the file you have downloaded and pass it into the resulting directory by executing the following command.
wget https://github.com/git/git/archive/v1.9.2.zip -O git.zip
unzip git.zip cd git-*You should now be able to make the package and install it by executing these commands below.
make prefix=/usr/local all sudo make prefix=/usr/local installNow that you have git installed, if you would like to upgrade to a later version, you can simply clone the repository before building and installing.
In order to find the URL to use to clone, go over to the branch or tag that you want on the project’s Github page and copy the clone URL on the right side. This should create a new directory inside the current directory where you can rebuild the package before reinstalling the newer version, same as you did in the above. Note that this will overwrite your older version with a newer version.
git clone https://github.com/git/git.git
make prefix=/usr/local all sudo make prefix=/usr/local install
How To Set Up GitYou should now have git installed, however, there are still a couple things you need to do in order to commit messages being generated for you will contain your correct information. The simplest way to do this is by using the git config command. Specifically, you will have to provide your name and email address as git embeds this information into every commit we do. Now you can add this information by executing these commands below.
git config --global user.name "Your Name" git config --global user.email "[email protected]"To see all of the configuration items that were set, execute the following command.
git config --list
user.name=Your Name [email protected]Now you can see, this kind has a slightly different format. The information is stored in the configuration file which you may optionally modify by hand with the text editor like shown here.
There are other options that you can choose, however, these are the ones which are most essential. If you skip this step then you will probably see warnings after you commit to git, the warning will look similar to the one below.
~/.gitconfig contents [user] name = Your Name email = [email protected]
This will make more work for you as you will have to then revise the commits you have made with the corrected information.
Output when git username and email not set [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 protected] After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author
ConclusionYou should now have git installed and ready to be used on your Ubuntu 14.04.
Updated on 03 Oct 2017
Add a comment