Save username and password in git

Lately I started to work on a new environment and the first thing has been to install git.

The second thing has been to clone a repository and finally I started to pull and push things.

But! Every time I pulled and pushed something a very nasty little window started bothering me: insert username, insert password (because of course the repository was protected by a password)

And if initially I endured it, after the third time I started to hate it.

So…I decided to save locally my git username and password.

First I had to type this

git config --global credential.helper store

and then

git pull (or push)

You will be prompt (for the LAST TIME) the git username and password

They will be stored in a .git-credentials file in a clear format like:

https://username:password@repository

Normally this file is saved in your local [username] folder (in windows or linux OS)

There is the possibility to have a secure (and recommended) method using a ssh key. Alternatively you can use a caching timeout way of saving your credentials (just in memory for a limited period of time).

For a complete documentation please refer to:

https://git-scm.com/docs/git-credential-store

https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage

0 Comments

Add Your Comment: