如何禁用Windows的Git Credential Manager?

Jez*_*Jez 151 git bash

我注意到,在Git中的最新版本,默认现在是弹出一个"混帐凭据管理器的Windows"对话框中,而不是在bash的提示我要我的密码提示每次的.我真的很讨厌这种行为.我怎样才能禁用它并返回每次在bash shell输入密码?

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

Jez*_*Jez 191

确定我发现您需要在Git for Windows安装程序期间AVOID检查"Git Credential Manager"复选框,或者(安装后)以管理员身份运行bash shell并使用git config --edit --system删除该helper = manager行以使其不再注册为凭据帮手.

对于奖励积分,使用git config --edit --global和插入:

[core]
    askpass =
Run Code Online (Sandbox Code Playgroud)

要禁用OpenSSH凭据弹出窗口.

  • 或者用`git config --system --unset credential.helper`敲出来 (35认同)
  • 谢谢你的回答.对我来说,这是第一次使用编辑器.如果要保存更改,请单击转义键并键入:wq并按Enter键(写入/保存并退出). (19认同)
  • 对于使用SourceTree的用户,请确保使用的是"系统"版本的GIT,而不是嵌入式版本.`工具 - >选项 - > Git`. (3认同)
  • 非常感谢!凭证管理器对我工作的代理服务器感到困惑,这让使用 Sourcetree 成为一场噩梦。禁用它立即解决了问题。 (2认同)
  • @cowlinator 我的系统文件位于“C:\Program Files\Git\etc\gitconfig”。至少这就是 `git config --edit --system` 打开的内容。我似乎在 %ProgramFiles%\Git\mingw64\etc 中没有 gitconfig (2认同)

Ian*_*cer 27

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

git-credential-manager.exe uninstall
Run Code Online (Sandbox Code Playgroud)

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

  • @ScottN 你正在运行`git-credential.exe`,但你需要运行`git-credential-manager.exe`。 (3认同)
  • 这只是停止,在我按下 ctrl-c 后,吐出这个用法:`git credential [fill|approve|reject]` (2认同)

Ste*_*rov 12

我必须与VSTS一起使用的另一个选择:

git config credential.modalprompt false --global

  • 谢谢!当我使用ssh远程连接到我的生产服务器时,我发现它非常有用:由于WCM脱壳,我无法做一个`git pull`.使用此选项,我喜欢这两个世界:WCM与服务器(或远程桌面)物理连接,并能够从ssh客户端拉. (3认同)

小智 9

对我来说没有用:

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...
Run Code Online (Sandbox Code Playgroud)

但是--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...
Run Code Online (Sandbox Code Playgroud)

我跑完后能看到那条痕迹:

set git_trace=1
Run Code Online (Sandbox Code Playgroud)

我还添加了git用户名:

git config --global credential.username myGitUsername
Run Code Online (Sandbox Code Playgroud)

然后:

C:\Program Files\Git\mingw64\libexec\git-core
git config --global credential.helper manager
Run Code Online (Sandbox Code Playgroud)

最后我把这个命令:

git config --global credential.modalPrompt false
Run Code Online (Sandbox Code Playgroud)

我检查ssh代理是否正在运行 - 打开一个bash窗口来运行此命令

eval "$(ssh-agent -s)"
Run Code Online (Sandbox Code Playgroud)

然后在计算机users/yourName文件夹中.ssh添加连接(仍然在bash中)

ssh-add .ssh/id_rsa

or

ssh-add ~/.ssh/id_rsa(if you are not in that folder)
Run Code Online (Sandbox Code Playgroud)

我检查了上面添加的所有设置:

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
Run Code Online (Sandbox Code Playgroud)

当我--force第一次再次这样做时,我不得不添加用户名并传递.

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.
Run Code Online (Sandbox Code Playgroud)

因为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
Run Code Online (Sandbox Code Playgroud)

完成这些设置后,我收到了一封电子邮件:

 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.
Run Code Online (Sandbox Code Playgroud)

我说这是因为我工作了.我希望这也能帮助别人.


Jur*_*sky 9

如果您发现在使用 JetBrains IDE(例如IntelliJ IDEAPhpStormWebStormPyCharmRiderRubyMineAndroid Studio或 Goland )时弹出凭证管理器 UI,请执行以下操作:

\n
    \n
  1. 在 IDE 中,转到菜单File \xe2\x86\x92 Settings \xe2\x86\x92 Version Control \xe2\x86\x92 Git

    \n
  2. \n
  3. 禁用使用凭据助手

    \n

    禁用“使用凭据助手”

    \n
  4. \n
  5. 不要忘记按Save

    \n
  6. \n
\n


Mar*_* Ba 8

我想将凭证管理器用于正常使用,但我有脚本,我显然不希望从git.exe. 这是我从脚本中调用 Git 的方式:

set GIT_TERMINAL_PROMPT=0
git -c core.askpass= -c credential.helper= <command> ...
Run Code Online (Sandbox Code Playgroud)

这样,脚本始终可以看到“正确”的无提示设置,而无需调整任何配置。

(适用于 Windows 2.13.3 的 Git)


我发现也可能派上用场的一个变体是设置:

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> ...
Run Code Online (Sandbox Code Playgroud)

但要注意,git.exe -c credential.interactive=never <command> ... 确实工作(似乎-c事不通过路由到Git的凭据管理器的Windows或其他)。

这样,您可以使用 GCMfW,但它永远不会提示您;它只会查找凭据,这在非交互式环境中非常有用。


小智 7

用:

C:\Program Files\Git\mingw64\libexec\git-core                                                                       
git credential-manager uninstall --force    
Run Code Online (Sandbox Code Playgroud)

这适用于 Windows 系统。我测试了它,它对我有用。


小智 7

很老的话题,但这可能对搜索上述提示未解决问题的人有所帮助。

我用

git credential-manager remove -force
Run Code Online (Sandbox Code Playgroud)


小智 7

我们在这个问题上苦苦挣扎。当我们尝试从 Git 存储库克隆代码时,没有提示(询问)Git 用户名和密码,它就开始克隆代码,并最终因身份验证失败而失败。甚至连凭据都没有设置,并且第一次使用 Git 克隆。

\n

解决方案:运行命令,它\xe2\x80\x99 可以正常工作。

\n
git config --system --unset credential.helper\n
Run Code Online (Sandbox Code Playgroud)\n


小智 6

我曾经有过这样的问题,我只取出 混帐凭据的manager.exe

C:\Program Files\Git\mingw64\libexec\git-core
Run Code Online (Sandbox Code Playgroud)


小智 6

也许问题出在Sourcetree上。

  1. 转到工具选项

  2. 取消选中“每 [10] 分钟检查默认遥控器的更新”

  3. 重新启动Sourcetree!