Configure and Use Git on Debian - Best Procedure ?

Git is a version control system that helps a user to keep history of certain files which are continuously edited. Due to rapid edits, it is impossible to keep the history of each change. Therefore, there are higher chances that the user may lose some data if something goes wrong. This is where git helps users to avoid unwanted circumstances. Git is not limited to individual users. It is even more helpful in a team environment. Each and every logged user who pushes changes can track their and other team members changes which takes teamwork to the next level.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform regular git commands queries.

In this context, we shall look into how to install, configure, and use the git version control system on Debian Linux System.

How to Configure Git ?

To configure git on Debian, simply follow the steps outlined below.

1. Start by installing git on our Debian system using the following command:

$ sudo apt install git

Once installed, you can check the version using git –version command.

2. Now we will configure git on priority, so when it comes to using git features we do not run into problems.

Register your name and email using the following commands:

$ git config --global "John Doe"
$ git config --global

The above commands will register both your name and email. Once done successfully, your name and email will display when you push the changes to the remote repository. In a different post, we will deal with how to configure a remote repository.

How to use Git ?

Now that we have installed Git and configured it successfully, we are going to use git.

1. Create a new directory using mkdir newRepo command:

$ mkdir newRepo
$ ls

2. Change the directory using cd /newRepo command.

3. We will now initialize the folder as a git repo. The below command will help us with this:

$ git init

4. Now we have a local repo and we will add some files into it then we'll check the status:

$ git add
$ git status

We have a new file in our local repository. Now we are going to commit and push the file using the following commands:

$ git commit -m "this is my first git commit"
$ git push origin master

[Need help in setting up Git on your Linux System ? We can help you. ]

This article covers steps to install and configure Git on a Debian 10 server. As one of the most popular version control systems currently available, Git is a common choice among open-source and other collaborative software projects. Many project's files are maintained in a Git repository, and sites like GitHub, GitLab, and Bitbucket help to facilitate software development project sharing and collaboration.

How to install Git on Debian / Ubuntu Linux System ?

1. Use the apt package management tools to update your local package index and then download and install Git:

$ sudo apt update
$ sudo apt install git

2. You can confirm that you have installed Git correctly by running the following command:

$ git --version

Related Posts