git-credential-oauth icon indicating copy to clipboard operation
git-credential-oauth copied to clipboard

Suggest clearing lower-priority credential helpers

Open FiloSottile opened this issue 3 months ago • 0 comments

As I set this up, I was confused by how git credential-cache exit wouldn't clear the refresh token.

Turns out, Homebrew sets /opt/homebrew/etc/gitconfig to

[credential]
	helper = osxkeychain

so my refresh tokens were ending up persisted.

There is a way around that:

If credential.helper is configured to the empty string, this resets the helper list to empty (so you may override a helper set by a lower-priority config file by configuring the empty-string helper, followed by whatever set of helpers you would like).

https://git-scm.com/docs/gitcredentials#Documentation/gitcredentials.txt-helper

Maybe the installation instructions should recommend that?

git config --global --unset-all credential.helper
git config --global --add credential.helper "" # disable system helpers
git config --global --add credential.helper "cache --timeout 21600" # six hours
git config --global --add credential.helper oauth

FiloSottile avatar Sep 30 '25 00:09 FiloSottile