我注意到,在最新版本的Git中,默认现在是弹出一个“Git凭证管理器for Windows”对话框,而不是每次在Bash提示符中提示我输入密码。
我真的很讨厌这种行为。我如何禁用它,然后回到每次在Bash shell中输入密码?
顺便说一下,我不希望Git以任何方式缓存我的凭据,无论是通过Windows凭据还是一些内部守护进程。我想禁用所有凭据缓存。
我注意到,在最新版本的Git中,默认现在是弹出一个“Git凭证管理器for Windows”对话框,而不是每次在Bash提示符中提示我输入密码。
我真的很讨厌这种行为。我如何禁用它,然后回到每次在Bash shell中输入密码?
顺便说一下,我不希望Git以任何方式缓存我的凭据,无论是通过Windows凭据还是一些内部守护进程。我想禁用所有凭据缓存。
当前回答
这对我不起作用:
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...
但是使用——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...
我可以在跑步后看到这个痕迹:
set git_trace=1
我还添加了Git用户名:
git config --global credential.username myGitUsername
然后:
C:\Program Files\Git\mingw64\libexec\git-core
git config --global credential.helper manager
最后我输入了这样的命令:
git config --global credential.modalPrompt false
检查SSH代理是否在运行
打开Bash窗口运行该命令
eval "$(ssh-agent -s)"
然后在。ssh所在的计算机用户/yourName文件夹中,添加一个连接(仍然是Bash):
ssh-add .ssh/id_rsa
or
ssh-add ~/.ssh/id_rsa (if you are not in that folder)
我检查了上面添加的所有设置:
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
当我再次git推送时,我不得不第一次添加用户名和密码。
git push
Please enter your GitHub credentials for https://myGithubUsername@github.com/
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.
自从使用git push之后,我再也没有输入git凭证的消息了。
D:\projects\react-redux\myProject (master -> origin) (budget@1.0.0)
λ 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
完成这些设置后,我也收到了一封电子邮件,上面写着:
A personal access token (git: https://myGitHubUsername@github.com/
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.
其他回答
我曾经有过这个问题,我只删除了git-credential-manager.exe文件:
C:\Program Files\Git\mingw64\libexec\git-core
如果你注意到当你使用JetBrains IDE(如IntelliJ IDEA, PhpStorm, WebStorm, PyCharm, Rider, RubyMine, Android Studio或Goland)时弹出凭据管理器UI,请这样做:
在你的IDE中,打开菜单文件→设置→版本控制→Git。 禁用使用凭据帮助器: 别忘了按Save键。
如果您不想删除或卸载凭据管理器:请参阅https://serverfault.com/questions/544156/git-clone-fail-instead-of-prompting-for-credentials/1054253#answer-1054253以获得适合我的解决方案。
说明等,在该页面(链接,以防止重复的内容在同一网站家族)。
TL;DR:这现在位于我的自动bash脚本之上:
# https://serverfault.com/questions/544156/git-clone-fail-instead-of-prompting-for-credentials
export GIT_TERMINAL_PROMPT=0
# next env var doesn't help...
export GIT_SSH_COMMAND='ssh -oBatchMode=yes'
# these should shut up git asking, but only partly: the X-windows-like dialog doesn't pop up no more, but ...
export GIT_ASKPASS=echo
export SSH_ASKPASS=echo
# We needed to find *THIS* to shut up the bloody git-for-windows credential manager:
# https://stackoverflow.com/questions/37182847/how-do-i-disable-git-credential-manager-for-windows#answer-45513654
export GCM_INTERACTIVE=never
证书管理器棺材上的最后一颗钉子是Martin Ba上面回答的唯一的位(GCM_INTERACTIVE):我如何禁用Windows的Git证书管理器?
对于前面答案中的提示无法解决的问题:
我使用
git credential-manager remove -force
我有另一个问题,设置git不提示任何密码,我学会了另一个命令行技巧,可以用于此目的。
如果你想要一个临时解决方案的终端会话,这可能会派上用场:
Git -c凭证。Helper = <其余的命令>