Re: [credential.helper] unexpectedly save credential to multiple credential files
On Fri, Nov 11, 2016 at 04:10:55PM +0800, Qi Nark wrote:
Show 9 quoted lines
> 1. git config --global credential.helper store
> 2. cd to a local repository directory, git config credential.helper
> store --file ./my_cred
> 3. execute some git command which need credential like git ls-remote
> 4. input my username & password, command done.
>
> As the result, **BOTH** the ./my_cred and ~/.git-credentials will save
> the credentials I just input. But, shouldn't the local config override
> the global ones, and only the ./my_cred should save it?
No, that's the expected result. The set of credential helpers form a list, and each is run in turn. From "git help credentials":
If there are multiple instances of the credential.helper configuration
variable, each helper will be tried in turn, and may provide a
username, password, or nothing. Once Git has acquired both a username
and a password, no more helpers will be tried.
That's talking about lookup, but the same principle applies to storage. But you may also find the paragraph below helpful:
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).
Note that the "reset" behavior was introduced in git v2.9.0, so you'll need at least that version.
-Peff