Skip to content

Instantly share code, notes, and snippets.

@ankurk91
Last active October 11, 2022 04:57
Show Gist options
  • Star 70 You must be signed in to star a gist
  • Fork 22 You must be signed in to fork a gist
  • Save ankurk91/f0b26f1c30d0d6d3ca4e to your computer and use it in GitHub Desktop.
Save ankurk91/f0b26f1c30d0d6d3ca4e to your computer and use it in GitHub Desktop.
Git credential cache, why type password again and again

Tired of entering password again and again ?

Run this command to remember your password:

git config --global credential.helper 'cache --timeout 28800'

Above command will tell git to cache your password for 8 hours.

How to make git forget this password ?

If you want to switch to another github account then u can run this command

git credential-cache exit

Above command will flush any stored password from cache.


Reference:

Windows User ?

git config --global credential.helper wincred

Ref for Windows: http://stackoverflow.com/questions/11693074/git-credential-cache-is-not-a-git-command

Mac OS user ?

Remove keychain from storing your password (When you are on a shared computer)

git config --system --unset credential.helper

Ref: https://stackoverflow.com/questions/16052602/disable-git-credential-osxkeychain

@normoes
Copy link

normoes commented Jun 8, 2018

Starting from which version of git is this possible?

This is really nice 👍
I definitely give it a try!

I settled with gpg and the system's keyring settings, but might be switching to what you have described here:

in ~/.gitconfig:

[credential]
helper = /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring

in ~/.gnupgp/gpg-agent.conf:

default-cache-ttl 3600
pinentry-program /usr/bin/pinentry-gtk-2

in ~/.gnupgp/gpg.conf:

# among others
use-agent

@Mashpy
Copy link

Mashpy commented Aug 30, 2021

Thanks for your gist. This article also helped me to solve the problem.

@avatarpp
Copy link

thanks!!

@JGeraldoLima
Copy link

Man, you saved my life with Windows, this configuration problem was driving me crazy! Thank you very much

@GladysMaria
Copy link

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment