How to Install Git on Ubuntu 22.04

0
Install Git on Ubuntu 22.04

So with the new release of Ubuntu 22.04, There are lots of new features included in the new version of Ubuntu. Some of the features are more productive than before and helpful if you are a developer or programmer. So if you are new to Ubuntu 22.04 then you have to install Git and in this article, you will get to know how to install Git on Ubuntu 22.04.

So Git is a free and open-source distributed version control system that helps to merge your code into a repository present in a platform such as GitHub. So being a developer or a programmer it is a must to have Git on your Ubuntu and you should also know how to install Git on Ubuntu 22.04.

How to install Git on Ubuntu 22.04

So being a developer for open source contributors you have to install Git to contribute to GitHub and if you are a previous user or an old user of Ubuntu 20.04 then you don’t need to install it because I just have to follow the below code.

$ sudo apt update
$ sudo apt upgrade

With the following code in your terminal, Git will be updated with the new version of Ubuntu.

Being a new user you have to follow the below steps to install and configure Git on Ubuntu 22.04 LTS.

  • Step 1 – Update Dependencies
  • Step 2 – Install Git
  • Step 3 – Configure Git
  • Step 4 – Confirm the Changes

Step 1- Update Dependencies on Ubuntu 22.04

Before installing Git on your system the first step is to open the command line terminal and update the dependencies of your system.

To do that write the below code in your terminal and run it

$ sudo apt update
$ sudo apt upgrade

Step 2- Install Git on Ubuntu 22.04

After updating the dependencies on your system now you are able to install git in your new Ubuntu 22.04 LTS version.

To do that Write the below code in your terminal and run it.

$ sudo apt install git -y

After installing Git on your system you will have to check the installed version of Git to confirm the command is successfully executed.

To check the version of your Git in Ubuntu 22.04  write the below code in your terminal and run it.

$ git --version

Step 3- Configure Git on your new Ubuntu 22.04

Now after installing Git on your updated system you will need to set up standard settings such as login credentials like email and your username of GitHub that will help you to commit the code changes in a repository of GitHub by your own account.

In the first step of configuration, you will have to provide your username that will be set globally.

To do that write the below code in your terminal and run it.

$ git config --global user.name "YOUR NAME"

Enter your GitHub username in the “your name” section.

In the next step, you have to enter an email that is connected with your GitHub username.

To do that write the below code in your terminal and run it.

$ git config --global user.email "YOUR EMAIL"

Enter your GitHub email in the “your email” section.

Step 4- Confirm the changes of Git on Ubuntu 22.04

After the configuration of Git by setting your GitHub email id and username you have to run a command to check whether the changes were made successfully.

To do that right the below code in your terminal and run it

$ git config --list

This will show if the changes have been made successfully in the GIT configuration file.

Store Git credentials on Ubuntu 22.04

You have successfully installed and configured Git on the new Ubuntu 22.0 4 LTS version.

Now if you are that kind of user who might want to keep authorization details secured, then you can do that by the credential helper cache using the following commands.

To do that write the following command in the terminal and run it

$ git config --global credential.helper cache

Now if you are using this credential helper for Git then you should only store the credentials for a limited time for increased security.

For example, if you are working today using get for 2 to 3 hours but won’t be touching it for a week then you should set the expiry of the cache credentials for 5 hours.

To do that write the following command in the terminal and run it.

$ git config --global credential.helper "cache --timeout=18000"

Set the cache Timeout according to your need such as how much time it can cache the credentials of Git.

In this case, the credentials will be deleted after 5 hours and that will increase the security of your Git.

How to update Git in Ubuntu 22.04 LTS

In the future if there is an update in Git then you can simply update your Git version by using the following command and the updates will be included with the Standard System packages that were installed git-core with APT package manager previously on Ubuntu 22.04 LTS.

$ sudo apt update && sudo apt upgrade

How to uninstall Git In Ubuntu 22.04 LTS

It is one of the most useful and most used Open source distributed version control systems and it helps to push your code changes to a repository in GitHub Other than that it also has more useful features that can be used while using GitHub.

But in some cases, you might no longer need Git installed on your system then you can simply uninstall Git from Ubuntu 22.04 by removing it using the following command.

$ sudo apt autoremove git -y

Now in the next step, you have to remove the PPA of Git using the same command as adding PPF but with a -remove flag in the command.

To do that right the following command in your terminal and run it.

$ sudo add-apt-repository --remove ppa:git-core/ppa -y

Read More: How to Install Git on Ubuntu 20.04 Easily

Conclusion

It is the most popular version control system for development and contribution to GitHub and there are many new releases of different applications that are uploaded there. Anyone using Git can share the solution to different issues in the community faced by the other users and the platform GitHub is accessible by every user because of Git.

So in this article, we have learned how to install Git on Ubuntu 22.04 LTS version with the configuration of Git, and also we have learned to store Git credentials using credential helper cache and how to uninstall Git on Ubuntu 20.04 LTS version.

LEAVE A REPLY

Please enter your comment!
Please enter your name here