How to setup Git on Ubuntu easily.

How to setup Git on Ubuntu easily.

Git is a powerful, open-source version control system that allows developers to track
changes in their codebase, collaborate with others, and manage their projects efficiently.
Setting up Git on Ubuntu is a straightforward process, whether you’re installing the
default version or a specific release. In this guide, we will walk you through the steps to
install Git on your Ubuntu VPS. If you’re looking for affordable and reliable VPS options, consider Veeble’s VPS services, which guarantee 99% uptime.

Step 1: Connect to Your Ubuntu Server via SSH

Step 2: Update Your System
Once you are logged in, run the following commands to update and upgrade your system:

sudo apt update -y && sudo apt upgrade -y


Step 3: There are two main methods to set up Git on Ubuntu :

Installing the default version or Installing a specific version.


Method 1: Install the Default Version of Git.


Git is often pre-installed on Ubuntu systems, so before installing it, you should check if it’s
already on your server. To check, run:

git --version


If Git is installed, you’ll see the installed version number in the output.
If Git is not installed, you can easily install it from Ubuntu’s official repositories with the
following command:

sudo apt install git


After installation, verify Git is installed by running:

git --version


Method 2: Install a Specific Version of Git


If you need a specific version of Git, follow these steps:


Install Required Libraries: To build Git from source, you’ll need to install some
essential libraries:

sudo apt install build-essential libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc -y


Download the Git Source Code: Next, download the source code for the version of
Git you wish to install(replace the version number with your desired version):

curl -L https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.45.2.tar.gz -o git-2.45.2.tar.gz


Extract the Downloaded File: Extract the contents of the tarball:

tar -zxf git-2.45.2.tar.gz


Compile and Install Git: Navigate to the extracted folder and compile Git:

cd git-2.45.2/
make prefix=/usr/local all
sudo make prefix=/usr/local install


Verify the Installation:

git --version

Conclusion

Git on Ubuntu offers easy installation, secure updates, and seamless integration with
IDEs like VS Code and IntelliJ. The command line provides flexibility, while customization
options allow automation to boost productivity. With optimized performance and a secure
version control system, it’s ideal for collaborative development.

Scroll to Top