• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Git on Debian 9 System

Written by Admin, Updated On May 7, 2019
debian, git
How To Install Git on Debian 9

Git is the most popular distributed version control system. It used to track changes in source code during software development. It allows to collaborate with programmers, revert to previous changes and create branches. In this tutorial, you will learn how to install Git on Debian system.

Prerequisites#

You must have logged in with non-root user account with sudo privileges.

Install Git on Debian with Apt#

Git is available at Debian default apt repository so we will install from there. It’s always recommended to install packages from Debian default repository.

So first of all we need to update apt package manager index using below command:

sudo apt update

Once the list is updated execute the below command to install Git:

sudo apt install git

You can verify the installation by typing:

git --version

It will show output like below:

Output
git version 2.11.0

That’s all. You have successfully installed Git version on you Debian system.

Installing Git from a Source#

Another installation method is to compile the software from source. It will allow you to download the latest release and to do customization. But you can’t manage Git package from apt package manager.

Before you start, you need to install necessary software which Git required. These all are available from default Debian repository. Execute below commands:

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

After that, you can go ahead and get the version of Git you want by visiting the Git project’s mirror on GitHub and copy the latest release link address that ends in .zip

https://github.com/git/git/releases

Now we will download Git source to /tmp directory on your Debian system. Move to /tmp directory by typing:

cd /tmp

Use the wget command to download the archive file as git.zip:

sudo wget https://github.com/git/git/archive/v2.21.0.zip -O git.zip

Once download is finished, unzip the downloaded file and move to the git source directory by typing:

unzip git.zip
cd git-*

Now, you can compile and install Git by typing these two commands:

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

Again, you can verify installation by typing:

git --version

It should show installed version of Git as given below:

Output
git version 2.21.0

Later, if you have need to upgrade to a newer version, you can repeat the installation process.

Setting Up Git#

Now your Git is installed and you need to configure it by setting up email address and username:

git config --global user.name "Admin"
git config --global user.email "admin@tecnstuff.net"

You can see entered details by typing:

git config --list
Output
user.name=Your Name
user.email=youremail@yourdomain.com

These settings are stored at ~/.gitconfig file and you can see content as below:

[user]
name = Admin
email = admin@tecnstuff.net

You can make other git configuration changes by using git config command or you can edit the ~/.gitconfig file manually.

Conclusion#

Finally, you have learned how to install Git on your Debian server and how to Setting up Git.

If you face any problem at installation time, leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Iptables on CentOS 7 Server
Next Article   How to Enable and Disable Root User Account in Ubuntu

Related Posts

  • How to Install and Configure Fail2ban on Debian 10

    How to Install and Configure Fail2ban on Debian 10

    June 6, 2021
  • How to Install Gitea on Ubuntu 20.04

    How to Install Gitea on Ubuntu 20.04

    May 31, 2021
  • How to Install LibreOffice 7.0 on Debian 10

    How to Install LibreOffice 7.0 on Debian 10

    January 25, 2021

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook