DebianDebian Based

How To Install Git on Debian 12

Install Git on Debian 12

In this tutorial, we will show you how to install Git on Debian 12. For those of you who didn’t know, Git’s powerful version control capabilities will now empower you to manage your projects efficiently and collaborate seamlessly with other developers.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Git database on a Debian 12 (Bookworm).


  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Git.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Git on Debian 12 Bookworm

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt install apt-transport-https lsb-release ca-certificates curl dirmngr gnupg

This command will refresh the repository, allowing you to install the latest versions of software packages.

Step 2. Installing Git on Debian 12.

There are multiple ways to install Git on Debian 12 Bookworm. However, the most straightforward method is using the default package manager, apt. Open the terminal and execute the following command to install Git:

sudo apt install git

During the installation, you may be prompted to confirm the action. Type ‘Y‘ and press Enter to proceed.

To ensure that Git has been successfully installed, execute the following command to display the installed Git version:

git --version

Step 3. Configuring Git.

  • A. Setting Up User Information:

Configuring user information in Git is essential, as it helps identify the author of commits. Use the following commands to set up your username and email address:

git config --global "idroot"
git config --global ""

Replace “idroot” with your desired name and “” with your preferred email address. The --global flag ensures that these settings are applied globally for all Git repositories on your system.

  • B. Configuring Text Editors:

By default, Git uses the system’s default text editor for commit messages and other operations. However, you can configure a different text editor if desired. For example, to set up Vim as the default text editor for Git, execute the following command:

git config --global core.editor "vim"

Step 4. Using Git: An Example Command Line:

  • A. Initializing a Git Repository:

To start using Git in a project, you need to initialize a Git repository. Navigate to your project’s directory in the terminal and execute the following command:

git init

This will create a hidden .git directory that contains the necessary files for Git to manage your project’s version control.

  • B. Adding and Committing Files:

Once you have a Git repository set up, you can start tracking changes to your files. To add a file to the staging area, use the following command:

git add <file_name>

Replace <file_name> with the actual name of the file, you want to add. To add all files in the current directory, you can use the dot notation:

git add .

After adding files to the staging area, commit the changes with a descriptive message using the following command:

git commit -m "Your commit message"

Replace “Your commit message” with a meaningful and concise description of the changes you made.

  • C. Checking the Repository Status:

To get an overview of the current status of your Git repository, including any modified files or untracked changes, execute the following command:

git status

This command will display detailed information about the state of your repository, helping you track progress and ensure everything is in order.

  • D. Pushing and Pulling Changes:

Collaborating with others often requires pushing and pulling changes between local and remote repositories. To push your local commits to a remote repository, use the following command:

git push origin <branch_name>

Replace <branch_name> with the name of the branch, you want to push.

To pull changes from a remote repository and update your local repository, execute the following command:

git pull origin <branch_name>

Step 5. Troubleshooting and Additional Resources.

  • If you encounter any errors during the installation process, make sure your system is up-to-date and check for any conflicting packages.
  • For advanced Git usage, including branching, merging, and resolving conflicts, refer to the official Git documentation and various online tutorials.
  • Stack Overflow and the Git community forums are excellent resources for troubleshooting specific issues or seeking guidance from experienced users.

Congratulations! You have successfully installed Git. Thanks for using this tutorial for installing the latest version of Git on Debian 11 Bookworm. For additional help or useful information, we recommend you check the official Git website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button