Install Git – Git Installation On Windows And CentOS

Recommended by 53 users

Nov 16, 2016
Install Git – Git Installation On Windows And CentOS
Add to Bookmark Email this Post 8.3K    2

Install Git

Let me guide you through the process to install Git in your system through this blog. In case you want to know more about Git don’t forget to checkout this blog.

In this Install Git blog you will learn:

Before you move ahead, check out this video on GIT installation.

Git Installation Tutorial for Beginners | Git Installation On Linux | DevOps Tools | Edureka

 

So, without any further ado, let us begin to install Git on a Windows system first.

Install Git On Windows

Step 1: To download the latest version of Git, click on the link below:

Download Git for Windows

Great! Your file is being downloaded.

Step 2:

After your download is completed, run the .exe file in your system.

Windows Run Git - Install Git - Edureka

Step 3:

After you have pressed the run button and agreed to the license, you will find a window prompt to select components to be installed.

Windows Select Components - Install Git - Edureka

After you have made selection of your desired components, Click on ‘Next>’.

Step 4:

This will take you to the next prompt window to make choices for adjusting your path environment. This is where you decide how do you want to use Git.

Windows Adjusting Path Environment - Install Git - Edureka

You can select any of the three options according to your needs. But for rookies I recommend using “Use Git From Git Bash Only”

Step 5:

The next step is to choose features for your Git. You get three options and you can choose any of them, all of them or none of them as per your needs. Let me tell you what these features are:

Windows Configuring Extra Features - Install Git - Edureka

The first is the option to enable file system caching.

Caching is enabled through Cache manager, which operates continuosly while Windows is running. File data in the system file cache is written to the disk at intervals determined by the operating system, and the memory previously used by that file data is freed.

The second option is to enable Git Credential Manager.

The Git Credential Manager for Windows (GCM) is a credential helper for Git. It securely stores your credentials in the Windows CM so that you only need to enter them once for each remote repository you access. All future Git commands will reuse the existing credentials.

The third option is to enable symbolic links.

Symbolic links or symlinks are actually advanced shortcuts. You can create symbolic links for each individual file or folder, and these will appear like they are stored in the folder with symbolic link.

I have selected the first two features only.

Step 6:

Choose your terminal.

Windows Configuring Terminal Emulator - Install Git - Edureka

You can choose one from the options.

The default terminal of MYSYS2 which is a collection of GNU utilities like bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present.

Or you can choose the window’s default console window (cmd.exe).

Step 7:

Now you have got all you need. Select “Launch Git Bash” and click on “Finish”.

Windows Finishing Git Installation - Install Git - Edureka

This will launch Git Bash on your screen which looks like the snapshot below:

Git Bash Terminal - Install Git - Edureka

Step 8:

Let us proceed with configuring Git with your username and email. In order to do that type the following commands in your Git Bash:

git config – – global user.name “<your name>”

git config – – global user.email “<your email>”

Git Windows Configuration - Install Git - Edureka

It is important to configure your Git because any commits that you make are associated with your configuration details.

If you want to view all your configuration details, use the command below:

git config – – list

Windows Git Configuration List - Install Git - Edureka

Your installation and setup of Git on Windows is all done and dusted! :-)

   Learn DevOps From Experts

Install Git on CentOS

Step 1:
First we need to install the software that Git depends on. These dependencies are all available in default CentOS repository.

Use the command:

sudo yum groupinstall “Development Tools”

Centos Git Installation Step 1 - Install Git - Edureka

It will ask for your confirmation to download the tools.

Centos Git Installation Step 2 - Install Git - Edureka

Press “Y” for Yes.

The “Development tools” which is a yum group, It is a predefined bundle of software that can be installed at once, instead of having to install each application separately. The Development tools will allow you to build and compile software from source code.

Now use the command:

sudo yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel

Centos Git Installation Step 3 - Install Git - Edureka

Enter your password. It will ask for your confirmation to download the package.

Centos Git Installation Step 4 - Install Git - Edureka

Press ‘Y’.

Now we are ready with the prerequisites. Lets proceed towards Git installation.

Step 2:

Now we are going to use wget command to download a specific version of Git.

Centos Git Installation Step 5 - Install Git - Edureka

 But first we need to copy the link of the version that we want to install. For that go to this website.

You will find the following webpage:

Centos Git Installation Step 6 - Install Git - Edureka

I am downloading git-2.7.2.tar.gz version of Git.

Now use the wget command with the link of the Git version you have chosen to install. Use the command below:

wget https://github.com/git/git/archive/v2.7.2.tar.gz -O git.tar.gz

Centos Git Installation Step 7 - Install Git - Edureka

This downloaded file will be available in my directory.

Step 3:

Once the download is complete we will extract the file from the downloaded Git Tar file. For that we will use Tar command.

tar -zxf git.tar.gz

Centos Git Installation Step 9 - Install Git - Edureka

Lets see the extracted folder.

Centos Git Installation Step 10 - Install Git - Edureka

There it is! :-)

Step 4:

Now lets change the directory to Git.

Use the command cd git

Centos Git Installation Step 11 - Install Git - Edureka

Step 5:

We are in the source folder we can begin the source build process. For that first type in the command:

make configure

Centos Git Installation Step 12 - Install Git - Edureka

Now use the following command:

make configure./configure –prefix=/usr/local

Centos Git Installation Step 13 - Install Git - Edureka

The configure script is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available Once configure has done its job, we can invoke make to build the software.

Step 6:

Now that the software is built and ready to run, the files can be copied to their final destinations. Use the command below:

sudo make install

Centos Git Installation Step 14 - Install Git - Edureka

The make install command will copy the built program, and its libraries and documentation, to the correct locations.

Step 7:

Now to check the version of Git installed  we will use the command:

git –version

Centos Git Installation Step 15 - Install Git - Edureka

Step 8:

Before we go ahead you need to submit some information about yourself so that commit messages will be generated with the correct information attached.
We need to provide Name and Email address that we would like to have embedded into our commits for that we will use commands:

git config –global user.name “Your Name”

git config –global user.email “you@example.com”

Centos Git Installation Step 16 - Install Git - Edureka

To confirm that these configurations are added successfully we will use the command  git config –list 

Centos Git Installation Step 17 - Install Git - Edureka

Step 9:

Now we need to generate a SSH key.
SSH is a secure protocol used as the primary means of connecting to Linux servers remotely. Now to generate a new SSH key we will use:

ssh-keygen -t rsa -b 4096 -C “your_email@example.com

Centos Git Installation Step 18 - Install Git - Edureka

It will ask you to enter the file name where you want to save the key. If you want it saved in your default directory press ‘Enter’. Enter blank passphrase if you want to and then enter the same again.

There is a program called ssh-agent that runs the duration of a local login session, stores unencrypted keys in memory, and communicates with SSH clients using a Unix domain socket. So to ensure that SSH agent is enabled we will use this command below:

eval “$(ssh-agent -s)”

Centos Git Installation Step 19 - Install Git - Edureka

To add SSH key to the SSH agent we will use

ssh-add ~/.ssh/id_rsa

Centos Git Installation Step 20 - Install Git - Edureka

To add SSH key to our GitHub account we will use:

cat ~/.ssh/id_rsa.pub

Centos Git Installation Step 21 - Install Git - Edureka

The gibberish you see on screen is actually the SSH key. ;-)

Finally we need to copy the SSH key and then we need to go to the GitHub account and click on settings.

(P.S. If you don’t have a GitHub repository and want to learn how to create it , skip here )

Centos Git Installation Step 22 - Install Git - Edureka

and then go to “SSH and GPG keys” option on the left.

Centos Git Installation Step 23 - Install Git - Edureka

 

We will now click on New SSH key and add title to it  and then paste the copied key in the space provided. Now we will click on add SSH key

Centos Git Installation Step 24 - Install Git - Edureka

Now use the below command to test the SSH key:

ssh -T git@github.com

Centos Git Installation Step 29 - Install Git - Edureka

Now we can see in the snapshot below that color of the key is green. It means we have successfully tested the key.

Centos Git Installation Step 25 - Install Git - Edureka

Now you are done with Git installation and connecting to your central repository on Git.

Create GitHub Repositories

You have learnt to install Git in your system and now its time to make repositories on GitHub that will act as your remote repository.

Step 1:

Go to “www.github.com” and like a piece of cake, all you need to do to Sign Up is fill up the following form and click on “Sign Up”.

Step 2:

Choose if you want your repositories to be private or public.

GitHub First Step - Install Git - Edureka

After choosing your plan, click on ”Continue”

Step 3:

Confirm your email and then click on “Start a project”.

GitHub Start A Project - Install Git - Edureka

Step 4:

Name your repository and click on “Create repository”.

GitHub Create Repository - Install Git - Edureka

Your repository will look like this snapshot below:

GitHub Repository - Install Git - Edureka

Now, you are all ready to commit, pull, push and perform all other operations. If you want to learn how to perform these operations and more, please checkout my Git Tutorial blog.

View Upcoming DevOps Batches

If you found this “Install Git” relevant, check out the DevOps training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. The Edureka DevOps Certification Training course helps learners gain expertise in various DevOps processes and tools such as Puppet, Jenkins, Nagios and GIT for automating multiple steps in SDLC.

Reshma AhmedAbout Reshma Ahmed (9 Posts)

Reshma is a tech-savvy professional working as a Research Analyst at Edureka. She is a DevOps evangelist, a Cloud enthusiast, a Big Data Hadoop fervid & a Data Visualization Jedi.


Share on
Comments
2 Comments
  • Jorge Olivos

    Hi Reshma,

    Good manual, congratulation.. just one clarification on the step wget:

    wget https://github.com/git/git/archive/v2.1.2.tar.gz -O git.tar.gz

    In the manual says that we are going to download the version 2.7 but in the wget says 2.1.2.

    Regards.

    • EdurekaSupport

      Hey Jorge, thanks for checking out our blog and for pointing out the mistake. We have corrected it in the blog. :) We are installing the 2.7.2 version itself. Cheers!

24 X 7 Customer Support X

  • us flag 1-800-275-9730 (Toll Free)
  • india flag +91 88808 62004