How to Configure and Save Username and Password (Credentials) for Git?

How to Configure and Save Username and Password (Credentials) for Git?

How to Configure and Save Username and Password (Credentials) for Git?

git tutorial

Entering a username and password every time while accessing a remote repository is a very tedious and time-consuming task.

No one wants to do that.

Use the following command to store GitHub/Gitlab credentials for automatic authentication.

git config --global credential.helper store 

A credential helper is a helper program that securely stores usernames and passwords used for authentication when interacting with remote Git repositories. 

In this case, we are using the “store” helper function and saving the credentials in a plane-text file on the local system.

Run the above command.

When you execute any git command that requires authentication, you will be prompted to provide a username and password.

Suppose you run

git push

You will be asked to enter your username and password. Once you enter the username and password, these credentials will be stored globally on your system.

You can always read the credentials from ~/.git-credentials file.

Next time you use any git command that requires authentication (like git clone, git push, git pull…) to access your remote repository, these credentials will be used by git automatically.

You don’t need to enter your username and password again.

Happy Coding!

1 Comment

  1. This is very time saving tip. I was wasting my time entering credentials for almost every git operation. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *