Saturday, September 24, 2022

How To Install Latest Git on Debian 11

In this guide, we want to teach you How To Install Latest Git on Debian 11.

By far, the most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. A staggering number of software projects rely on Git for version control, including commercial projects as well as open source.

Steps To Install Latest Git on Debian 11

To install Git, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Debian 11.

Now follow the steps below to install git in the latest version.

Installing Git From Source on Debian 11

For those that want the latest Git version, it is recommended to always install from the source.

First, update your local package index with the following command:

sudo apt update

Then, you need to install the Dependencies on your server by us

sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip -y

Now you need to visit the Git Release page and find the master zip archive or the latest stable release from Git.

Next, use the wget command to download the Latest git on Debian 11:

wget https://github.com/git/git/archive/refs/tags/v2.37.3.zip

When your download is completed, unzip your file with the command below:

sudo unzip v2.37.3.zip

Switch to your Git directory:

cd git-2.37.3

At this point, use the following commands to install the Git:

# sudo make prefix=/usr/local all
# sudo make prefix=/usr/local install

When you are done, verify your Git installation on Debian 11 by checking its version:

git --version
Output
git version 2.37.3

Setup and Configure Git on Debian 11

At this point, you must configure Git so that the generated commit messages you make will contain the correct information and support you as you build your software project.

You must provide your name and email address because Git embeds this information into each commit you do. To do this, you can use the following commands:

# git config --global user.name "Your Name"
# git config --global user.email "[email protected]"

After setting up the user name and email ID, you can verify the details using git config --list command:

git config --list
Output
user.name=Your Name
user.email=[email protected]

All the configuration done through the git command will save the information in a file called .gitconfig in the user’s home directory. So you can also verify the configuration by checking this file using cat ~/.gitconfig command as shown below:

cat ~/.gitconfig
Output
[user]
   name=Your Name
   email=[email protected]

Testing Git

Now that you have set up Git on Debian 11, you can try using it by performing git clone operations from GitHub.

We can just clone a repository called wig by using git clone https://github.com/jekyc/wig.git command as shown below. This will create a directory wig in your local system and copy all the contents from the repository:

git clone https://github.com/jekyc/wig.git
Output
Cloning into 'wig'...
remote: Enumerating objects: 4240, done.
remote: Total 4240 (delta 0), reused 0 (delta 0), pack-reused 4240
Receiving objects: 100% (4240/4240), 4.47 MiB | 7.89 MiB/s, done.
Resolving deltas: 100% (2832/2832), done.
Checking connectivity... done.

Also, you can check all the subcommands available with the git command using git help -a command as shown below:

git help -a
Output
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]

available git commands in '/usr/local/libexec/git-core'

add merge-index
add--interactive merge-octopus
am merge-one-file
annotate merge-ours
apply merge-recursive
archimport merge-resolve
archive merge-subtree
bisect merge-tree
bisect--helper mergetool
blame mktag
branch mktree
.....

That’s it.

Conclusion

At this point, you learn to Install Latest Git on Debian 11.

Hope you enjoy it.

You may be inserted in these articles:

How To Install MongoDB Server on Debian 11

Set up and configure NTP Server and Client on Debian 11

Install and Use Vagrant on Debian 11

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular