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

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

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


当前回答

好吧,我发现你需要避免在Git for Windows安装过程中选中“Git Credential Manager”复选框,或者(在安装之后)以管理员身份运行Bash shell,并使用Git config——edit——system删除helper = Manager行,以便它不再注册为凭据助手。

为了加分,使用git config -edit -global并插入:

[core]
    askpass =

要禁用OpenSSH凭证也弹出。

其他回答

我在Ubuntu 18.10 (Cosmic Cuttlefish)上遇到了同样的问题,无法使用任何正常方法删除。 我使用git config -global -unset credential。帮手,这似乎奏效了。

Use:

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

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

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

这对我不起作用:

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.

也许问题出在Sourcetree上。

点击工具→选项 取消选中“每[10]分钟检查默认远程更新” 重启Sourcetree !