Skip to content
Related Articles

Related Articles

How to Add Git Credentials in Linux?

Improve Article
Save Article
  • Last Updated : 07 Mar, 2022
Improve Article
Save Article

Git is a commonly used free and open-source version control system. It’s a tool used for source code management. It is used to handle from very small projects to very large projects with great efficiency. In git, a version control system records all the changes that are made to the source code over time into a special database that is known as ‘Repository’ where one can look at the project history and see who has made what changes and when. Git can be installed on various operating systems like Windows, macOS, Linux, etc.

Installing git on Linux 

First of all, we will see how to install git on Linux step by step:

Step 1: Go to the official website, and click on the button named ‘Download for Linux’. It will display different commands to install git on different Linux Distributions.


Step 2: Now copy the installation command as per your Linux distribution(here we use Ubuntu) from the download page. 


Some of the commonly used distribution commands are:


$ apt-get install git


$ yum install git (up to Fedora 21)

$ dnf install git (Fedora 22 and later)


$ emerge –ask –verbose dev-vcs/git

Arch Linux:

$ pacman -S git

For other distributions of linux, visit the website.

Step 3: Now copy the required command and paste it on the terminal and hit enter, after that enter the password, and then git will be successfully installed in the system.

sudo apt-get install git


NOTE: If we are using ubuntu Debian or any of their derivatives then git already comes installed with git, but the version is (1:2.25.1), which is not the latest version available. To update the version of git to the latest, follow step 5.

Step 4: To get the latest version of git for Ubuntu, use the following command on the terminal.

$ sudo add-apt-repository ppa:git-core/ppa

$ sudo apt-get install git -y


We can also check the version of git installed by executing the following command.

$ git –version


Adding credentials to Git

Once git is successfully installed on the system, we can head on to adding the credentials to Git, which can be achieved using the following command

$ git config –global “Your Name”

$ git config –global “”

In order to return the list of the configuration we’ve provided to Git, we can use the following command.

$ git config –list


To see where the configuration files are being saved we need to read the .gitconfig file, which is located in the home directory. The highlighted section represents the credentials file which can be displayed using the following command.

$ gedit .gitconfig


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!