Announcement

Collapse
No announcement yet.

Install Git on Ubuntu 24.04

Collapse
X
Collapse
  •  

  • Install Git on Ubuntu 24.04

    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...
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    There are no tags yet.

    Latest Articles

    Collapse

    • HAProxy on Ubuntu: Load Balancing and Failover for Resilient Infrastructure
      by Kasimba



      by german.suarez


      Introduction

      In today’s fast-paced digital landscape, ensuring the availability and performance of applications is paramount. Modern infrastructures require robust solutions to distribute traffic efficiently and maintain service availability even in the face of server failures. Enter HAProxy, the de facto standard for high-performance load balancing and failover.


      This article...
      Today, 03:00 PM
    • Providing a license for package sources
      by Kasimba
      Arch Linux hasn't had a license for any package sources (such as PKGBUILD files) in the past, which is potentially problematic. Providing a license will preempt that uncertainty.

      In RFC 40 we agreed to change all package sources to be licensed under the very liberal 0BSD license. This change will not limit what you can do with package sources. Check out the RFC for more on the rationale and prior discussion.

      Before we make this change, we will provide contributors with...
      11-19-2024, 09:21 AM
    • Linux Binary Analysis for Reverse Engineering and Vulnerability Discovery
      by Kasimba



      by George Whittaker


      Introduction

      In the world of cybersecurity and software development, binary analysis holds a unique place. It is the art of examining compiled programs to understand their functionality, identify vulnerabilities, or debug issues—without access to the original source code. For Linux, which dominates servers, embedded systems, and even personal computing, the skill of binary analysis is...
      11-18-2024, 07:10 PM
    • Ubuntu vs Debian: Linux Distributions Compared Deep Dive
      by Kasimba
      Debian and Ubuntu are two popular Linux distributions. In this deep dive we will guide you on the key differences between them from perspective of both corporate enterprise and personal productivity or pleasure usage. After reading this blog post you should be in a better position to decide to select Ubuntu or Debian.
      Stewardship, Licensing, Community and Cost

      Where as Debian is 100% fully committed to free software as defined by the Debian Free Software Guidelines, Ubuntu is created...
      11-17-2024, 08:30 PM
    • Debian Backup and Recovery Solutions: Safeguard Your Data with Confidence
      by Kasimba



      by George Whittaker


      Introduction

      In the digital age, data loss is a critical concern, and effective backup and recovery systems are vital for any Debian system administrator or user. Debian, known for its stability and suitability in enterprise, server, and personal computing environments, offers a multitude of tools for creating robust backup and recovery solutions. This guide will explore these solutions,...
      11-13-2024, 05:30 PM
    • Installing Development Tools on Debian: Setting Up Compilers, Libraries, and IDEs for a Robust Development Environment
      by Kasimba



      by George Whittaker


      Introduction

      Debian is one of the most trusted and stable Linux distributions, making it a top choice among developers and system administrators. Setting up a powerful development environment on Debian involves installing the right tools, compilers, libraries, and Integrated Development Environments (IDEs) that can support various programming languages and workflows. This guide provides...
      11-07-2024, 11:22 PM
    Working...
    X