Git is an open-source distributed control system to efficiently manage the source code of small as well as large projects. The user might have installed it using the apt package manager of Debian/Ubuntu-based Linux distributions and want to update to the newer version of git; to get the most advanced features and functionalities of sharing and editing the project’s source code.
This post will cover the methods to upgrade the current version of git to a newer version using the apt package manager in Linux.
- How to Update the Newer Version of Git Using APT?
Note: For the installation of Git in Linux, read our latest article on it.
How to Update to a Newer Version of Git Using APT?
The user can update the current version of git to the latest one without removing it. This can be done by adding the “git-core/ppa” repository in the system and installing the git.
Follow the subsequent steps to update the git to the latest version:
Step 1: Check the Current Git Version
Let’s check the current version of git available in the operating system:
$ git --version
The current version of git is “2.34.1” that is already installed in the system.
Step 2: Add PPA Repository
In order to update the version of git, add the following repository in the operating system to install git dependencies:
$ sudo apt-add-repository ppa:git-core/ppa
The “git-core” PPA repository is added.
Note: If users get an error while adding the repository, run the “sudo apt install software-properties-common” command to install dependencies:
Step 3: Update Packages
Once the repository is added, update the system packages using the “apt” command as below:
$ sudo apt update
After executing the above common, the package list has been updated.
Step 4: Install Newer Version of Git
Now, install the git using the apt package manager as shown:
$ sudo apt install git
The latest version of git is installed.
Verify the Change
Let’s verify the version of the git in the terminal:
$ git --version
The git version is upgraded to “2.40.0,” which is the newer version on the official website.
To update the git to the latest version, add the “git-core” repository by executing the “sudo apt-add-repository ppa:git-core/ppa” command. Then, update the system packages and install git using the “sudo apt install git” command. After that, verify the version of git.
This write-up has illuminated the step-by-step procedure of updating the git to the latest version.