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 Ibmi Media, 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 user.name "John Doe"
$ git config --global user.email firstname.lastname@example.org
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
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 ReadMe.md
$ 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. ]