How to install Git on AWS EC2 Amazon Linux 2

We can easily download Git from almost all Linux distributions using the integrated package manager. Here we will see how to install GIT on Amazon Linux running on AWS Ec2 Instance.

Git is a freely available open-source system for distributed versioning. It is fast, scalable, and system version control (logging of adjustments) of files. As we know in the programming world while writing hundreds of codes there are always frequent changes happened. And these changes can be monitored and reversed with the help of GIT; further files can be made available to others via “repositories” or changes can be obtained from others.

If required, adjustments from publicly accessible repositories (repos) can be imported into a “working copy” or you can make your own adjustments available to others. This gives a programmer better control over each version of the file’s, complete history and track of changes done. This is all without any central server. It is an open-source, hence Git is also often used as a development platform, including for the Linux kernel.


Steps to install Git on Amazon Ec2 Linux

1. Connect to Ec2 Instance

There are two easy ways to connect Ec2 Instance running Linux one is using the Web Console and the other via SSH from your local system’s command prompt or terminal.

For Web Terminal

Just select your Instance and click on the Connect button given in the Top menu.

Select Created Instance

After that again click on the Connect button.

Connect Instance using web console

Those who like to use a local PC system’s terminal or SSH client they can see our tutorial- How to SSH AWS ec2 Linux Instances remotely


2. Run system update

Before installing Git, let’s run the system update command on Amazon Ec2 Linux, this will update the existing packages and also refresh the system’s repository cache.

sudo yum update


3. Install git in Amazon EC2 instance

We don’t need to add any third-party repository to get the Git on our Amazon Linux 2, simply use the default YUM package manager and you will have it on your cloud VM via the amzn2-core system repo. Here is the command to follow:

sudo yum install git


4. Check Git Version

Once the installation is completed let’s check the Git version available on our system.

git version


5. Let’s Setup a local repository for Git

Create a directory 

mkdir mygit

Get into the created directory

cd mygit/

Now, initialize git local repository

git init

You can see the content

ls -a .git/

To have the git status, the command is:

git status

To list all git commands and sub-commands

git help -a

Get help for some particular command 

git help <command>

GIT install on AWS ec2 Amazon Linux 2

For more information refer to the Git documentation.



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.