How do I disable git’s credential helper for a single repository?

With git 2.9 (June 2016), this (helper = ) will actually work!

See commit 2432137 (26 Feb 2016) by Jeff King (peff).
(Merged by Junio C Hamano — gitster in commit 1b68962, 03 Apr 2016)

The credential.helper configuration variable is cumulative and there is no good way to override it from the command line.
As a special case, giving an empty string as its value now serves as the signal to clear the values specified in various files.

credential: let empty credential specs reset helper list

Since the credential.helper key is a multi-valued config list, there’s no way to “unset” a helper once it’s been set. So if your system /etc/gitconfig sets one, you can never avoid running it, but only add your own helpers on top.

Since an empty value for credential.helper is nonsensical (it would just try to run “git-credential-“), we can assume nobody is using it. Let’s define it to reset the helper list, letting you override lower-priority instances which
have come before.


Even more convenient: With Git 2.26 (Q1 2020), this override applies even for any value.

See commit 46fd7b3, commit 82eb249, commit 588c70e, commit 732f934, commit 3fa0e04 (20 Feb 2020) by brian m. carlson (“).
(Merged by Junio C Hamano — gitster in commit 2cbb058, 05 Mar 2020)

credential: use the last matching username in the config

Signed-off-by: brian m. carlson

Everywhere else in the codebase, we use the rule that the last matching configuration option is the one that takes effect.

This is helpful because it allows more specific configuration settings (e.g., per-repo configuration) to override less specific settings (e.g., per-user configuration).

However, in the credential code, we didn’t honor this setting, and instead picked the first setting we had, and stuck with it.

This was likely to ensure we picked the value from the URL, which we want to honor over the configuration.

It’s possible to do both, though, so let’s check if the value is the one we’ve gotten over our protocol connection, which if present will have come from the URL, and keep it if so.

Otherwise, let’s overwrite the value with the latest version we’ve got from the configuration, so we keep the last configuration value.


Note: user202729 adds in the comments:

If credential helper A is set as global and you want to use B in a local repository (change, not remove the helper), use:

git config --local credential.helper ''
git config --local --add credential.helper B

The first empty item removes the global setting A.

Equivalently, set two lines helper = and helper = B in .git/config.

Leave a Comment