As a developer, version control systems are essential to your daily work, especially in enhancing collaboration with other developers. If you use Git as your VCS, understanding how to install it on Ubuntu 24.04 is handy.
With Git, you can comfortably track changes in your repository, revert changes, and more. Moreover, Git makes it easy to maintain your code in Git repositories. Before you can use Git on Ubuntu 24.04, you must know how to install it. Luckily, there are two installation options, and both are detailed in this guide.
Two Methods of Installing Git on Ubuntu 24.04
Installing Git only requires access to a non-root user account and an internet connection. The method to use will depend on your preference. If you want a quick and easy way, installing Git from the Ubuntu repository is recommended. However, this method doesn’t install the latest Git version.
If you want the latest version, you must install Git from its source. This approach involves more steps, but it gets the job done once you know which commands to run.
Method 1: Install Git on Ubuntu 24.04 from Ubuntu Repository
Git is available in the default packages on Ubuntu, and this version is considered more stable despite not being the latest version. Again, this method allows you to install Git using APT with a simple command.
Some packages are installed by default, and in Ubuntu 24.04, you should have Git already installed. Verify this by checking its version.
$ git --version
If Git is not installed in your case, start by updating your package list.
$ sudo apt update
After updating the package index, we can then install Git as follows.
$ sudo apt install git
It’s that simple. Once the process runs and completes, Git will be available on your system, and you can configure it to start using it.
If you want to install the latest Git version, use the following method.
Method 2: Install Git on Ubuntu 24.04 from Source
With the first method, we managed to install Git, but the installed version was not the latest. When you source packages from the default repository, you only access the latest stable version.
However, this doesn’t mean you can’t get the latest Git version. To do so, you must compile Git from the source. Unlike the previous method, this approach takes more time, and you must run different commands to retrieve the package and compile it.
Step 1: Install the Dependencies
For us to source and compile Git, different packages are required, and we can install them using the command below.
$ sudo apt install libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc
Those already installed will be skipped during the installation.
Step 2:Create a Temporary Directory
We need a temporary directory to store and compile the retrieved Git files. We’ve named the directory tmp and navigated into it.
$ mkdir tmp
$ cd /tmp
Step 3: Download the Latest Git Version
You can only find the latest Git version from its website. To know which version you should download, visit the Git project website. Once the site loads, locate the latest version. We have v2.44.0 as the latest when writing this post.
Next, use curl to download the Git tarball with the below command.
$ curl -o git.tar.gz https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.44.0.tar.gz
Ensure you replace the command to match the latest version, depending on when you read this post.
Step 4: Unpack the Tarball
Once you download the Git tarball, we must unpack it using tar. After unpacking, use the cd command to navigate to the Git directory.
$ tar -zxf git.tar.gz
$ cd git-*
Step 5:Compile and Install Git
Start by Compiling the Git package using the make command.
$ make prefix=/usr/local all
Afterward, install the package by running the command below.
$ sudo make prefix=/usr/local install
Lastly, apply the changes with the command below.
$ source /etc/environment
That’s it. You now have Git installed. Check the version to confirm that we installed the latest one.
$ git --version
We have v 2.44.0, which is what we downloaded earlier.
Configure Git on Ubuntu 24.04
Now that you’ve installed Git, the next recommended step is to configure your username and email. To achieve this, run the below commands and add your username to use when making a commit and the email address.
$ git config --global user.name “your_name"
$ git config --global user.email "your_email"
You can now start using Git to make your commits on your repository.
Conclusion
Git is a widely used version control system, and there are two methods for installing it on Ubuntu 24.04. First, you can install it via APT from your default packages. Alternatively, you can source and compile the Git package to get the latest version. That’s it!
More...
Categories
Collapse
Article Tags
Collapse
There are no tags yet.
Latest Articles
Collapse
-
by Kasimba
by George Whittaker
Introduction
In the world of operating systems, Windows has long held the lion’s share of the market. Its user-friendly interface and wide compatibility have made it the default choice for many. However, in recent years, Linux has steadily gained traction, challenging the status quo with its unique offerings. What was once considered the domain of tech enthusiasts and developers is now...-
Channel: Articles
Yesterday, 06:52 AM -
-
by KasimbaOverview of NGINX and Apache
NGINX and Apache are leading web server solutions utilized for hosting websites and web applications. Apache, developed by the Apache Software Foundation, offers robust configuration options and extensibility. NGINX, created by Igor Sysoev, is known for its efficiency in handling numerous concurrent connections with low resource utilization. Both servers function not only as HTTP servers but also as reverse proxies, load balancers, and more.
What is
...-
Channel: Articles
Yesterday, 03:54 AM -
-
by KasimbaHi everyone, I hope you are enjoying the BETA so far! This release introduces new features, tools, and artwork, so we anticipate a good number of bug reports. Every single fix helps us refine and improve the final release. Your feedback during the BETA phase is extremely important to us. Linux Mint 22.1 is our […]
More...-
Channel: Articles
12-16-2024, 11:50 AM -
-
by Kasimba
by George Whittaker
Introduction
Remote access is a cornerstone of modern IT infrastructure, enabling administrators and users to manage systems, applications, and data from virtually anywhere. However, with great power comes great responsibility—ensuring that remote access remains secure is paramount. This is where OpenSSH steps in, providing robust, encrypted communication for secure remote management....-
Channel: Articles
12-13-2024, 10:31 PM -
-
by Kasimba
by George Whittaker
Introduction
The grep command, short for "global regular expression print," is one of the most powerful and frequently used tools in Unix and Linux environments. From sifting through log files to finding patterns in text, grep is a Swiss Army knife for system administrators, developers, and data analysts alike. However, many users limit themselves to its basic functionality, unaware...-
Channel: Articles
12-13-2024, 09:24 PM -
-
by KasimbaThis is the BETA release for Linux Mint 22.1 “Xia”. Linux Mint 22.1 is a long term support release which will be supported until 2029. It comes with updated software and brings refinements and many new features to make your desktop even more comfortable to use. New features: This new version of Linux Mint contains […]
More...-
Channel: Articles
12-12-2024, 09:31 AM -