bash 如何禁用 Windows 版 Git 凭据管理器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37182847/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I disable Git Credential Manager for Windows?
提问by Jez
I notice that in the latest version of Git, the default is now to popup a "Git Credential Manager for Windows" dialog instead of prompting me for me password at the Bash prompt every time.
我注意到在最新版本的 Git 中,现在默认是弹出一个“Windows 的 Git 凭证管理器”对话框,而不是每次都在 Bash 提示中提示我输入密码。
I really hate this behaviour. How can I just disable it and go back to entering the password at the Bash shell every time?
我真的很讨厌这种行为。我怎样才能禁用它并返回到每次在 Bash shell 中输入密码?
By the way, I don't want Git caching my credentials in any way, whether through Windows credentials or some internal daemon. I want to disable all credential caching.
顺便说一下,我不希望 Git以任何方式缓存我的凭据,无论是通过 Windows 凭据还是某些内部守护程序。我想禁用所有凭据缓存。
回答by Jez
OK, I discovered that you need to either avoidchecking the "Git Credential Manager" checkbox during the Git for Windows installer, or (after installation) run the Bash shell as Administratorand use git config --edit --system
to remove the helper = manager
line so that it is no longer registered as a credential helper.
好的,我发现您需要避免在 Git for Windows 安装程序期间选中“Git Credential Manager”复选框,或者(安装后)以管理员身份运行 Bash shell并用于git config --edit --system
删除该helper = manager
行,使其不再注册为凭证助手。
For bonus points, use git config --edit --global
and insert:
对于奖励积分,请使用git config --edit --global
并插入:
[core]
askpass =
To disable the OpenSSH credentials popup too.
也禁用 OpenSSH 凭据弹出窗口。
回答by Ian Mercer
I was able to uninstall the Git Credential Manager for Windows using the uninstall option:
我能够使用卸载选项卸载适用于 Windows 的 Git Credential Manager:
git-credential-manager.exe uninstall
Run this command in C:\Program Files\Git\mingw64\libexec\git-core
运行此命令 C:\Program Files\Git\mingw64\libexec\git-core
回答by Sten Petrov
Another option I had to use with VSTS:
我必须与 VSTS 一起使用的另一个选项:
git config credential.modalprompt false --global
git config credential.modalprompt false --global
回答by Sten Petrov
It didn't work for me:
它对我不起作用:
C:\Program Files\Git\mingw64\libexec\git-core
git-credential-manager.exe uninstall
Looking for Git installation(s)...
C:\Program Files\Git
Updated your /etc/gitconfig [git config --system]
Updated your ~/.gitconfig [git config --global]
Removing from 'C:\Program Files\Git'.
removal failed. U_U
Press any key to continue...
But with the --force
flag it worked:
但是有了--force
标志,它就起作用了:
C:\Program Files\Git\mingw64\libexec\git-core
git credential-manager uninstall --force
08:21:42.537616 exec_cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
e
08:21:42.538616 git.c:576 trace: exec: git-credential-manager uninstall --force
08:21:42.538616 run-command.c:640 trace: run_command: git-credential-manager uninstall --force
Looking for Git installation(s)...
C:\Program Files\Git
Updated your /etc/gitconfig [git config --system]
Updated your ~/.gitconfig [git config --global]
Success! Git Credential Manager for Windows was removed! ^_^
Press any key to continue...
I could see that trace after I run:
运行后我可以看到该跟踪:
set git_trace=1
Also I added the Git username:
我还添加了 Git 用户名:
git config --global credential.username myGitUsername
Then:
然后:
C:\Program Files\Git\mingw64\libexec\git-core
git config --global credential.helper manager
In the end I put in this command:
最后我输入了这个命令:
git config --global credential.modalPrompt false
I check if the SSH agent is running - open a Bash window to run this command
我检查 SSH 代理是否正在运行 - 打开 Bash 窗口以运行此命令
eval "$(ssh-agent -s)"
Then in the computer users/yourName folder where .ssh is, add a connection (still in Bash):
然后在 .ssh 所在的计算机 users/yourName 文件夹中,添加一个连接(仍在 Bash 中):
ssh-add .ssh/id_rsa
or
ssh-add ~/.ssh/id_rsa(if you are not in that folder)
I checked all the settings that I add above:
我检查了我在上面添加的所有设置:
C:\Program Files\Git\mingw64\libexec\git-core
git config --list
09:41:28.915183 exec_cmd.c:236 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-cor
e
09:41:28.917182 git.c:344 trace: built-in: git config --list
09:41:28.918181 run-command.c:640 trace: run_command: unset GIT_PAGER_IN_USE; LESS=FRX LV=-c less
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
credential.modalprompt=false
credential.username=myGitUsername
And when I did git push
again I had to add username and password only for the first time.
当我git push
再次这样做时,我只需要第一次添加用户名和密码。
git push
Please enter your GitHub credentials for https://[email protected]/
username: myGithubUsername
password: *************
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 316 bytes | 316.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
Since then using git push
, I don't have the message to enter my Git credentials any more.
从那以后使用git push
,我没有再输入我的 Git 凭据的消息。
D:\projects\react-redux\myProject (master -> origin) ([email protected])
λ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 314 bytes | 314.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/myGitUsername/myProject.git
8d38b18..f442d74 master -> master
After these settings I received an email too with the message:
完成这些设置后,我也收到了一封电子邮件,其中包含以下消息:
A personal access token (git: https://[email protected]/
on LAP0110 at 25-Jun-2018 09:22) with gist and repo scopes was recently added
to your account. Visit https://github.com/settings/tokens for more information.
回答by Henry Vásquez
I had had that problem, and I've only removed the git-credential-manager.exefile from:
我遇到了这个问题,我只从以下位置删除了git-credential-manager.exe文件:
C:\Program Files\Git\mingw64\libexec\git-core
回答by Martin Ba
I wanted to use the credential manager for normal use, but I have scripts where I obviously do not want any prompts whatsoever from git.exe
. This is how I invoke Git from my scripts:
我想将凭证管理器用于正常使用,但我有脚本,我显然不希望从git.exe
. 这是我从脚本中调用 Git 的方式:
set GIT_TERMINAL_PROMPT=0
git -c core.askpass= -c credential.helper= <command> ...
This way, the script always sees the "correct" no-prompt setting without having to adapt any configuration.
这样,脚本始终可以看到“正确”的无提示设置,而无需调整任何配置。
(Git for Windows 2.13.3)
(适用于 Windows 2.13.3 的 Git)
A variation I found that might also come in handy is to set:
我发现也可能派上用场的一个变体是设置:
set GCM_INTERACTIVE=never
# Or: git config --global credential.interactive never
set GIT_TERMINAL_PROMPT=0
git.exe -c core.askpass= -c credential.helper=manager <command> ...
But note that git.exe -c credential.interactive=never <command> ...
does notwork (it seems that the -c
thing isn't routed through to Git Credential Manager for Windows or whatever).
但要注意,git.exe -c credential.interactive=never <command> ...
确实不工作(似乎-c
事不通过路由到Git的凭据管理器的Windows或其他)。
That way, you canuse the GCMfW, but it will never prompt you; it will just lookup the credentials, which can be very helpful in non-interactive environs.
这样,您可以使用 GCMfW,但它永远不会提示您;它只会查找凭据,这在非交互式环境中非常有用。
回答by Martin Ba
Use:
用:
C:\Program Files\Git\mingw64\libexec\git-core
git credential-manager uninstall --force
This works on Windows systems. I tested it, and it worked for me.
这适用于 Windows 系统。我测试了它,它对我有用。
回答by hatanooh
Maybe the problem is Sourcetree.
也许问题是Sourcetree。
Go to Tools→ Options
Uncheck "Check default remotes for updates every [10] minutes"
Restart Sourcetree!
转到工具→选项
取消选中“每 [10] 分钟检查默认遥控器的更新”
重新启动源树!
回答by wanton
I struck the same issue on Ubuntu 18.10(Cosmic Cuttlefish), unable to remove using any normal means.
I used git config --global --unset credential.helper
, and that seemed to do the trick.
我在Ubuntu 18.10(Cosmic Cuttlefish)上遇到了同样的问题,无法使用任何正常方法删除。我使用了git config --global --unset credential.helper
,这似乎可以解决问题。
回答by user3437639
and if :wq doesn't work like my case use ctrl+z for abort and quit but these will probably make multiple backup file to work with later – Adeem Jan 19 at 9:14
如果 :wq 不像我的情况那样工作,请使用 ctrl+z 中止并退出,但这些可能会使多个备份文件稍后使用 – Adeem 1 月 19 日 9:14
Also be sure to run Git as Administrator! Otherwise the file won't be saved (in my case).
还要确保以管理员身份运行 Git!否则文件将不会被保存(在我的情况下)。