# Tahir Hassan's Blog

My Technical Notes

## Wednesday, 17 June 2015

### Git: caching credentials

To set-up caching for our password, we have to set the credential.helper option. This will set the credential caching for the repository you are currently in. Later, we describe how to set this option globally.

#### Windows Credential Store

To store passwords permanently in the Windows Credential Store, do:


git config credential.helper wincred


To then delete a password, open the Credential Manager:


Control Panel\User Accounts\Credential Manager


#### Cache (Memory)


git config credential.helper 'cache --timeout=3600'


will store the credentials for 60 minutes. You can tweak --timeout.

#### Store (on disk)


git config credential.helper store


will store the credentials in ~/.git-credentials. This is a plain text file and therefore is probably not the best option. See [1] for more information.

#### Setting option globally

If you wish to set a default, for example, by default you want the credential to be stored in memory for 12 hours (or 43200 seconds) after typing them in (within the same session), you need to add the --global argument:


git config --global credential.helper 'cache --timeout=43200'


Global settings are stored in ~/.gitconfig, but they can be overridden by settings stored in the repository, which are stored in .git/config.

Therefore if you set the credential.helper option for a repository, this will override the global option.