我注意到,在最新版本的Git中,默认现在是弹出一个“Git凭证管理器for Windows”对话框,而不是每次在Bash提示符中提示我输入密码。

我真的很讨厌这种行为。我如何禁用它,然后回到每次在Bash shell中输入密码?

顺便说一下,我不希望Git以任何方式缓存我的凭据,无论是通过Windows凭据还是一些内部守护进程。我想禁用所有凭据缓存。


当前回答

Visual Studio Code: Menu File→Preferences→Configuration→GitHub→gitAuthentication: false。将存储库的协议从https://更改为git://,并对git使用公钥身份验证。

其他回答

我可以使用卸载选项卸载Git Credential Manager for Windows:

git-credential-manager.exe uninstall

在C:\Program Files\Git\mingw64\libexec\git-core中执行该命令

这对我不起作用:

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.

Use:

C:\Program Files\Git\mingw64\libexec\git-core                                                                       
git credential-manager uninstall --force    

这适用于Windows系统。我测试过了,对我很有效。

我有另一个问题,设置git不提示任何密码,我学会了另一个命令行技巧,可以用于此目的。

如果你想要一个临时解决方案的终端会话,这可能会派上用场:

Git -c凭证。Helper = <其余的命令>

如果:wq不像我的情况下,使用ctrl+z中止和退出,但这些可能会使多个备份文件工作稍后- Adeem 1月19日9:14

另外,一定要以管理员身份运行Git !否则文件将不会被保存(在我的情况下)。