How to Install Git on Amazon Linux 2023 Instance

How to Install Git on Amazon Linux 2023 Instance

How to Install Git on Amazon Linux 2023 Instance

Dear Reader, how are you doing today? In my last few posts, I have shared with you how to install Ansible, NginxApache Web ServerDockerJava etc. on Amazon Linux 2023 or AL2023 EC2 Instance.

In today’s post, we’ll discuss how to install Git on Amazon Linux 2023 EC2 instance.

Does that sound interesting?

Alright, let’s start.

Don’t want to miss any posts from us? join us on our Facebook group, and follow us on Facebook, Twitter, LinkedIn, and Instagram. You can also subscribe to our newsletter below to not miss any updates from us.

Hello Amazon Linux 2023(AL2023) and Git

Amazon Linux 2023: Amazon Linux 2023 or AL2023 is the next-generation Amazon Linux AMI provided by AWS. It is rpm based and optimized for the cloud. It is designed with the latest Linux innovations to deliver high-performance and stable Linux systems.

Git: Git is a widely popular distributed version control system. Basically, you use it for source code management. The good thing about git is it is free and open source. Additionally, it can handle projects of any scale efficiently. 

Prerequisite

Firstly, before you install Git on your Amazon Linux 2023 or AL2023 EC2 instance, You should have an EC2 instance up and running.

Here is how you can launch an Amazon Linux 2023-

Additionally, if you don’t have a free tier account, check out how to setup a free tier AWS account in right way. Having said that, don’t forget to set up a cost budget to avoid last-minute billing shocks.

Steps to Install Git on Amazon Linux 2023 Instance

  1. Connect to your Amazon Linux 2023 Instance
  2. Search Git Package
  3. Update your Instance with the Latest Package
  4. Install Git on your Amazon Linux 2023
  5. Verify Git Installation
  6. Configure Basic Details(Optional)
  7. Setup a Simple Repository(Optional)

Step 1: Connect to your Amazon Linux 2023 Instance

If you have an EC2 running on Amazon Linux 2023 AMI. you are good to install Git on it. If not, create one using one of my previous tutorials.

Once your instance is up and running, select your instance and click on Connect as shown in the below screenshot.

How to Install Nginx on Amazon Linux 2023 Instance 1

Verify that ec2-user is showing in the user-name field and click Connect again.

In a matter of seconds, you are inside your instance as shown below.

Steps to Install Java on Amazon Linux 2023 Instance

Important Note: If you prefer connecting from your local, feel free to use the command- ssh -i /path/my-key-pair.pem ec2-user@instance-public-ip

Step 2: Update System Package

As we have always done, update your system packages to the latest before installing any software.

You can run the system update using the below command-

sudo dnf update

Type sudo dnf update and hit enter.

How to Install Java on Amazon Linux 2023 Instance 1

Step 3: Search Git Package

Let’s search for the Git package available on Amazon Linux 2023.-

sudo dnf search git
How to Install Git on Amazon Linux 2023 Instance

Step 4: Install Git on your Amazon Linux 2023

As you saw the package name above, the one line to install git on your Amazon Linux 2023 would be –

sudo dnf install git -y

You can also remove -y from the above command if you want to see what’s getting installed along with Git as a dependency. As you can see in the below screenshot, once you enter y or N , it gets installed or not depending on that.

How to Install Git on Amazon Linux 2023 Instance 2

Type y and hit enter.

How to Install Git on Amazon Linux 2023 Instance 3

As you can see Git along with dependencies gets installed on your Amazon Linux 2023.

Step 5: Verify Git Installation

As we installed Git, let’s verify it.

git --version
How to Install Git on Amazon Linux 2023 Instance 3

Congratulation !!!

You have successfully installed Git on your Amazon Linux 2023 EC2 Instance.

Step 6: Configure Basic Details(Optional)

One of the most important configurations, after you install Git, is to set up your user name /email. Because it’s very important to know who did what changes on a repo.

use the below command –

git config --global user.name "Preeti Jha"
git config --global user.email "[email protected]"

Don’t forget to change the email and name with your own before hitting the command.

Basic Configuration

Step 7: Set up a Simple Git repository(Optional)

Let’s create a folder, navigate inside it and initialise it as a git repo.

mkdir demo
cd demo
git init
How to Install Git on Amazon Linux 2023 Instance 3

Conclusion

In this how-to article, we discussed How to Install Git on Amazon Linux 2023 Instance. We learnt that Git is available on the core repository and very straightforward to install.

We installed Git using sudo dnf install git and verified the Git installation. Later we also did basic Git configuration and set up a simple repository on our Amazon Linux 2023.

Were you able to install Git on Amazon Linux 2023 using this tutorial? Let me know in the comment section.

Enjoyed the content?

Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.

Don’t forget to motivate us-

Suggested Read:

Leave a Reply

Your email address will not be published. Required fields are marked *