Now Reading: Git Installation Process on Ubuntu

Loading
svg
Open

Git Installation Process on Ubuntu

January 15, 20248 min read

Git is a fast, reliable, and adaptable distributed version control system. It is designed to support distributed, non-linear workflows, making it ideal for software development teams of all sizes. Each Git working directory is a self-contained repository with a complete history of all changes and the ability to track versions even without network access or a central server.

GitHub is a git repository hosted on the cloud that provides all the features of distributed revision control. GitHub is a repository for git, hosted on the cloud. Unlike Git, which is a CLI tool, GitHub has a web-based GUI. It is used for version control including collaborating with other developers and tracking changes made to scripts and code over time. With GitHub, each team member can create a cloud-based central repository and change data, making collaboration on projects possible.

This post demonstrates how to get Git on your Ubuntu system.

Git installation on Ubuntu

There are three main methods of installing Git on Ubuntu:

  1. Using Ubuntu Package Manager (Apite)
  2. Using Git Maintainers PPA
  3. from git source

Method 1: Install GIT using the default APT repository on Ubuntu 22.04

Step 1: Update the system

Updated packages are essential to create a strong foundation for Git installation on your Ubuntu system. By taking this action, potential package conflicts are reduced during installation.

You can update your system's packages by using the “Update” command in “Advanced Packaging Tools”.

Output:

It is recommended that any older packages be upgraded once the update is complete. Use this command to perform this upgrade:

Production,

Step 2: Check for existence of Git on Ubuntu

It is advisable to confirm whether Git is already present on your machine before continuing with the installation. This allows us to avoid duplicate installations and keep our system clean.

To check if Git is already present on your system, use the “git” command with -version. If Git is installed, it shows the version already installed:

Output:

Step 3: Use apt commands

If the previous command returns nothing, verify that Git is not installed on your machine. Now it's time to install Git.

Since it offers an easy-to-use process, we install Git using Ubuntu's repositories. Install Git by using sudo apt to run the “install” command.

Output:

Step 4: Verify if GIT installation of Ubuntu is successful

Once the installation is finished, you should make sure that Git is installed correctly.

Once again, we can verify the installation with -version. At this point, the most recently installed version of Git should be returned by this command:

You should see something like this when the command runs:

Method 2: Install GIT on Ubuntu via Git Maintainers PPA

It can sometimes be better to work with the latest Git version, especially when new features or important bug fixes are required. The Ubuntu Git maintainers team maintains the Personal Package Archive (PPA) which is usually the source of the latest stable version of Git. Depending on your particular needs and your working environment, this approach can have several major benefits.

Step 1: Import Git Maintainers PPA

We need to add the Git PPA to the repository list of our system. Access to the latest stable Git releases is guaranteed by this PPA. Even though your system probably already has the following packages installed, it's never a bad idea to double-check.

sudo add-apt-repository ppa:git-core,PPA

Output:

Step 2: Refresh the package index after PPA import

After importing the Git PPA into your system's repository list, you need to refresh the package index. Now that the repository has been added, your system is able to recognize recently downloaded packages.

To update the package index:

Step 3: Use apt ppa command to install git

Step 3: Use apt ppa command to install git

Once the PPA is set up, you can upgrade or install Git. This command does this:

Output:

If you have already installed Git from Ubuntu's repositories you can upgrade Git to the latest version from the additional PPA by running this command.
After the upgrade or installation is finished, confirm the installed Git version:

Production,

You should see something like this:

This indicates that the latest Git version is properly installed on your machine.

Checking the repository from which your Git installation originated can provide you with more information. Because PPAs usually contain a very recent version of Git, using the following command should reflect the latest PPA addition:

Output:

Method 3: Installing Git via source

This method gives users more control over the installation process and access to specific features that may not be included in a pre-packaged distribution.

Step 1: Configure Ubuntu with GIT Build Dependencies

First of all, you need to install the required build dependencies on your Ubuntu system. These requirements are needed to implement Git compilation. To configure these, use the following:

sudo apart to install Make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev receive text to open -y

Output:

Step 2: Get GIT Source Code

go to git release page To get the source code. To download the desired version, use the following command. Don't forget to replace {version} with the required Git version.

curl -O git.tar.gz https:,mirrors.edge.kernel.org,Pub,software,SCM,git,git-2.37.1.tar.gz

Output:

Step 3: Extract and Install Git Source Code

Now, compile and install GIT. To start compilation, use the following:

Locate and open the extracted directory:

Output:

Now, compile and install GIT. Start compilation using the following:

sudo Make Prefix,,usr,local All

This command instructs the build system to expect an installation into the “/usr/local” folder at the end of the compilation process. The “all” flag assures a complete build that includes all components.

After compilation is finished, start the installation:

sudo Make Prefix,,usr,local to install

Output:

Git is now installed in the “/usr/local” directory. The process involves copying the necessary files and granting the necessary permissions to make Git accessible on your machine.
Verify that the build is accurate and the installation was successful.

Production,

This command should confirm that Git has been properly integrated into your system by returning the version you installed.

conclusion

Git is a widely used and powerful distributed version control system. This article demonstrates how to install Git on Ubuntu 22.04 and earlier versions. We discussed three methods: using the Ubuntu Package Manager (APT), using the Git Maintainers PPA, and using Git Source. You can find many online resources, such as the official Git manual, to help you learn how to use Git.

How do you vote?

0 People voted this article. 0 Upvotes - 0 Downvotes.
svg

What do you think?

Show comments / Leave a comment

Leave a reply

You may like
Loading
svg