Want to learn how to install git on ubuntu? Then you are not lost, you have come to the right place.
Let's take a crash course on everything git.
Before proceeding, does anyone know git exactly means?
In definition, git is a version control system.
Let's just assume that you are a graphic designer who is working on a huge project.
You must at least need to create 2 versions of the same image to please your clients. But when you are working a huge project, at times you have to make work on many versions.
The client may like one of your images but what about the rest of the others you worked hard on? You could always recycle and use it for other projects.
Saving all the version of the same image could get tedious over time. That is where a version control system will help you.
It will help you revert the image or any file back to its previous state. It can do the same for your entire project.
Apart from that, you can also stop worrying if you are prone to losing files. Recovering files is a simple task with version control system at hand
So, what is a git server?
Now we know that Git is a distributed version control system. It can also be used as a server.
The tasks of Git server include displaying all the content of a Git repository using the web, adding access control, and it also helps in managing the multiple repositories.
By installing Git you can have all the features that an open source git server provides.
Ubuntu 16.04 server installed. If you don't have it installed you can refer the ubuntu download and server setup guide.
There are two ways to install Ubuntu 16.04.
You could do it the easy way that might get you there sooner but lacks a few things or the hard way that might have you take the longer route but will help you get all the features.
The Easy Way:
Install git on ubuntu 16.04 using apt.
Before you go any further, here's a warning. Using this method to install git on Ubuntu might be the easiest but you will not get the recent version. You will get the version that is older to the latest version.
This method uses Ubuntu's default repositories.
You could start out by updating your local package index.
sudo apt-get update
When you have updated it, the next step involves installing git on your system.
sudo apt-get install git
The above command line will help you download Git as well as install it on your system.
Hard Way: Install Git on Ubuntu 16.04 from the source.
Follow the steps to get the latest version of git and git server download on your system.
First, you need to update the local package index.
Before you begin, you need to install the software that git depends on.
This is all available in the default repositories, so we can update our local package index and then install the packages:
sudo apt-get update sudo apt-get install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
Visit the Git Source Code Mirror on GitHub using this link.
Take a look the below screenshot's. It will give you an idea of what you have to while downloading the package.
As you can see by default the branch is set to master.
You can click on it and select tag, then you can select the latest version of git.
Avoid the rc versions.
Select the latest version that doesn't have rc.
Once that is done, click on the clone or download button. Then right-click on the download zip button and copy the link address.
Copy that link address to your ubuntu server after the wget command.
This will download the zip file to your system.
Unzip the zip file you downloaded.
Then set the current directory to git.
unzip git.zip cd git-*
The next step is about creating the package.
Use the make command as follows.
make prefix=/usr/local all sudo make prefix=/usr/local install
Next, we will be using ubuntu git clone command to clone the repository.
This git clone command example will help you understand how the command works.
You are going to need an URL for cloning. Return to the mirror. Copy the URL.
Set your home directory as the current directory.
cd ~ git clone https://github.com/git/git.git -O git.zip
Above code will create a new directory in your home directory. This is done to overwrite the old version with the latest version.
cd git make prefix=/usr/local all sudo make prefix=/usr/local install
Look at the code is quite similar to what you did before when you created the package.
This installs git on your ubuntu 16.04.
You can see why this long route was the hard way.
Getting started with Git.
After you have installed Git there are few things that you need to take care of first. The foremost on the list is adding your name and email id.
This is important because now the generated commit messages will have your correct information.
We will avoid the long route this time and go for the easy way by using the git config command.
git config --global usern.name "add your name" git config --global usern.email "firstname.lastname@example.org"
To view the content in the configuration you can use the following command line.
git config --list
usern.name=add your name
From the output, you can surmise that the information is stored in the git configuration file.
You can edit these details by using the text editor on your ubuntu 16.04. Just type in the below command line.
This is what you will see next.
[usern] name = Your Name email = email@example.com`
Sure, you can not follow these steps and just be content with installing git and go about your way. But if you want to avoid getting warnings every time you commit to git, use this.
That will help you set up git on ubuntu 16.04.
For ubuntu github has the mirror repository where you can find all the downloads.
Links for which has been provided in the post. You will not have to go searching for them.
Hope that you have no trouble in installing Git on your Ubuntu 16.04.