How To Install Git On Ubuntu 2024 Guide
Install Git on Ubuntu using APT Package Manager
You can install git on Ubuntu using the APT package manager by following the below-given steps:
Step 1: Update the Ubuntu System
First, update the Ubuntu repositories of all dependencies before you can install git:
Then, upgrade the system for any pending upgrades:
Step 2: Install Git from Official Repository
Next, use this command to install the latest stable version of git from the official Ubuntu repositories: Press the ‘y’ key on the keyboard when prompted for confirmation.
Step 3: Verify the Installation
Once git is installed on your Linux machine, use this command to verify the installation with its version number. If you get the version number as the output, your installation is successful.
Install Git on Ubuntu from the Source Code
With Git being completely free and open source, you can directly compile from its source or even modify its contents to your preferences and then install it on your Ubuntu system.
Step 1: Download the Required Dependencies
Use this command to install all the dependencies required to build Git from its source code:
Step 2: Download the Source Code
Head over to the official Git release page on GitHub and click on the version number you want to download.
Then, right-click on “Source code (tar.gz)” and copy the link.
Next, use this syntax to download and save the Git file to the /usr/src:
For example, if you have selected the v2.41.0, use this command:
Step 3: Compile and Install Git
Now, all that’s left for you to do is compile and install git on your Ubuntu system using this command:
Step 4: Verify Installation
Once the installation finishes, verify the Git installation using the following command: