search
HomeComputer TutorialsComputer KnowledgeGit installation process on Ubuntu

Git installation process on Ubuntu

Mar 20, 2024 pm 04:51 PM
gitgithubstorage

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 an independent 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 Git repository hosted on the cloud. Unlike Git which is a CLI tool, GitHub has a web-based graphical user interface. It is used for version control, which involves collaborating with other developers and tracking changes made to scripts and code over time. With GitHub, every team member can create a central cloud-based repository and make changes to data, enabling project collaboration.

This article demonstrates how to get Git on an Ubuntu system.

Git installation on Ubuntu

There are three main ways to install Git on Ubuntu:

  1. Using Ubuntu Package Manager (APT)
  2. Using Git Maintainers PPA
  3. Source: Git

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

Step 1: Update the system

When installing Git on an Ubuntu system, it is crucial to use updated packages. Doing so can help mitigate package conflicts that may arise during the installation process and ensure a smooth installation process.

You can use the "Update" command in the "Advanced Packaging Tool" to update the system's software package.

Sudoku APT update

Output:

Git installation process on Ubuntu

It is recommended to upgrade any outdated packages after the update is complete. Use this command to perform this upgrade:

sudo apt upgrade

Output:

Git installation process on Ubuntu

Step 2: Check if Git exists on Ubuntu

It is recommended to confirm whether Git already exists on your computer before proceeding with the installation. This allows us to avoid repeated installations and keep the system clean.

Use the "git" command and --version to check whether Git already exists in the system. If Git is installed, the previously installed version is displayed:

git——version

Output:

Git installation process on Ubuntu

Step 3: Use APT command

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

Because it provides an easy-to-use process, we install Git using Ubuntu's repository. Run the "Install" command using sudo apt to install Git.

Sudo apt install git

Output:

Git installation process on Ubuntu

Step 4: Verify that Ubuntu’s GIT installation is successful

After the installation is complete, you should ensure that Git is installed correctly.

Once again, we can use -version to verify the installation. At this point, the following command should return the most recently installed Git version:

Git-version

When the command runs, you should see something like this:

Git installation process on Ubuntu

Method 2: Install GIT on Ubuntu via Git Maintainer PPA

It is sometimes better to use the latest Git version, especially when new features or critical bug fixes are needed. The Ubuntu Git maintenance team maintains the Personal Package Archive (PPA), which is usually the source of the latest stable version of Git. Depending on your specific needs and your work environment, this approach may have a number of major benefits.

Step 1: Import Git Maintainer PPA

We need to add the Git PPA to the system's repository list. Access to the latest stable Git version is guaranteed by this PPA. Even though your system may already have the following packages installed, it's not a bad thing to recheck.

SUDO add-apt-repository-ppa:git-core/ppa

Output:

Git installation process on Ubuntu

Step 2: Refresh package index after PPA import

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

To update the package index, do the following:

Sudoku APT update

Step 3: Install git using apt ppa command

Step 3: Install git using apt ppa command

You can upgrade or install Git once the PPA is set up. This command performs this task:

Sudo apt install git-y

Output:

Git installation process on Ubuntu

If you have installed GIT from the Ubuntu repository, you can upgrade Git from the additional PPA to the latest version by running this command.
After the upgrade or installation is completed, confirm the installed Git version:

git——version

Output:

You should see something like this:

Git installation process on Ubuntu

This indicates that the latest version of Git is installed correctly on your computer.

Checking the repository your Git installation came from can give you more information. Because PPAs usually contain a newer version of Git, using the following command should reflect the latest PPA additions:

APT-Cache Strategy Git

Output:

Git installation process on Ubuntu

Method 3: Install Git from source

This method gives the user more control over the installation process and grants access to specific features that may not be included in the prepackaged distribution.

Step 1: Configure Ubuntu using GIT Build Predencies

First, you need to install the necessary build dependencies on your Ubuntu system. These requirements are required for Git compilation. To configure these, use the following commands:

Sudo apt install make libssl-dev libghc-zlib-dev libcurl4-Gnutls-dev libexpat1-dev gettext decompression-y

Output:

Git installation process on Ubuntu

Step 2: Get the GIT source code

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

curl—o git.tar.gz www.example.com

Output:

Git installation process on Ubuntu

Step 3: Extract and install GIT source code

Now, now compile and install git. To start compilation, use the following command:

sudo tar—xf git.tar.gz

Find and open the unzipped directory:

cd git—2.37.1

Output:

Git installation process on Ubuntu

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

sudo make prefix =/usr/local all

Git installation process on Ubuntu

This command instructs the build system to install in the "/usr/local" folder at the end of the compilation process. The "all" flag ensures a complete build including all components.

After compilation is completed, start the installation:

sudo make prefix =/usr/local install

Output:

Git installation process on Ubuntu

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.

git——version

Output:

Git installation process on Ubuntu

This command should confirm that Git is properly integrated into your system by returning your installed version.

in 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. We discussed three methods: using the Ubuntu Package Manager (apt), using the Git Maintainer PPA, and using Git source code. You can find many online resources, such as the official Git manual, to help you learn how to use Git.

The above is the detailed content of Git installation process on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
Download Hidester VPN/Proxy to Access Your Favorite Content - MiniToolDownload Hidester VPN/Proxy to Access Your Favorite Content - MiniToolApr 22, 2025 am 12:50 AM

Learn about Hidester VPN and Hidester proxy and download Hidester VPN for Windows, Mac, Android, and iOS to use this VPN service to view websites with no limit. For more useful free computer tools and troubleshooting tips, you may visit php.cn Softwa

Windows Keyboard Opening Shortcuts Instead of Typing [Fixed]Windows Keyboard Opening Shortcuts Instead of Typing [Fixed]Apr 22, 2025 am 12:48 AM

Have you ever encountered the trouble of “Windows keyboard opening shortcuts instead of typing”? In this post from php.cn, you will learn how to fix this issue.

Easy Ways to Add the Control Panel Icon to Desktop on Win 10 / 11Easy Ways to Add the Control Panel Icon to Desktop on Win 10 / 11Apr 22, 2025 am 12:46 AM

In this post, php.cn Software will introduce what Control Panel is and how to add the Control Panel icon to desktop on your Windows 10 or Windows 11 computer. You can also learn some related information about desktop icon settings.

Granblue Fantasy Relink Save File Location & Backup Save DataGranblue Fantasy Relink Save File Location & Backup Save DataApr 22, 2025 am 12:45 AM

If you play Granblue Fantasy: Relink on your PC, you may wonder where you can find its save file. In this post, php.cn introduces everything you want to know - Granblue Fantasy Relink save file location and how to back up the savegame of this game.

How to Fix Event ID 1104: The Security Log Is Now Full? - MiniToolHow to Fix Event ID 1104: The Security Log Is Now Full? - MiniToolApr 22, 2025 am 12:44 AM

Event Viewer keeps track of activity for better management. However, if the upper limit of the security log is reached, no more events can be logged. In this post on php.cn Website, we will show you how to deal with Event ID 1104 the security log is

Watch: How to Enable Secure Boot on Gigabyte Motherboard?Watch: How to Enable Secure Boot on Gigabyte Motherboard?Apr 22, 2025 am 12:43 AM

Secure Boot is a security standard that can prevent your computer from booting with untrustworthy software. Enabling it will add an extra layer of security to your device. In this post from php.cn Website, we will show you how to enable Secure Boot o

Windows 11 23H2 Release Date: September 26, 2023 - MiniToolWindows 11 23H2 Release Date: September 26, 2023 - MiniToolApr 22, 2025 am 12:42 AM

Coming to a new year, what Windows 11 users are looking forward to are not only the patch updates but also the annual major update for Windows 11. This post will talk about the Windows 11 23H2 release date. In addition, if you want to recover deleted

How to Turn off Bixby on Samsung Phone? See a Guide! - MiniToolHow to Turn off Bixby on Samsung Phone? See a Guide! - MiniToolApr 22, 2025 am 12:41 AM

Can you completely disable Bixby? How to turn off Bixby on Samsung phones? It is not hard to disable this voice assistant. In this post from php.cn, we will go to any length to help you find the method. Besides, a way to turn off “Hi, Bixby” is also

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.