I'd like to use some git credentials for only single command.
git -c remote.origin.url="http://pass:user@gitserver/GitRepo" push
But after doing that credentials are saved in Credential Manager (i can see them in Windows Credential Manager), and are used implicitly for the subsequent git push
commands.
How do I prevent storing them?
You might want to disable the use of the Windows Credential Manager in one of three different scopes:
In all cases, the answer is to unset the credential.helper
in your configuration, but how you do it depends on the scope.
Run
git config --global credential.helper ""
and Git will no longer store credentials anywhere for you.
Once you've cloned a sandbox, you can disable the credential manager for operations inside that sandbox only with this command:
git config --local credential.helper ""
Finally, you can use -c
on the command line for one time overrides:
git -c credential.helper= <some command>
If you're going to disable credential management for a single repo, you'll actually have to use the -c
variant when you clone the repo, to turn off credential storage on clone, and the --local
setting in that sandbox, to turn off credential storage on push/pull/fetch operations.
If you change your mind later, you can undo things by removing your own config setting that disables credential management:
git config --global --unset credential.helper
or
git config --local --unset credential.helper
This way, you go back to the system default (that's manager-core
in my Git for Windows configuration, which uses the Windows Credential Manager).
Or, you can set your own credential manager choice explicitly, globally or in the sandbox, with:
git config --global credential.helper manager-core
or
git config --local credential.helper manager-core