Open In App

How to Add Git Credentials in Linux?

Last Updated : 07 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Download-for-Linux

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

Commands-for-installation

Some of the commonly used distribution commands are:

Debian/Ubuntu:

$ apt-get install git

Fedora:

$ yum install git (up to Fedora 21)

$ dnf install git (Fedora 22 and later)

Gentoo:

$ 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

Installing-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

Getting-the-latest-version-of-git

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

$ git –version

Version-of-Git

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 user.name “Your Name”

$ git config –global user.email “youremail@domain.com”

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

$ git config –list

Adding-credentials-to-Git

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

Reading-.getconfig-fileDisplaying-the-credentials


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads