【问题标题】:Make git ask for credentials from the command-line让 git 从命令行请求凭据
【发布时间】:2020-04-27 17:26:41
【问题描述】:

当 git 要求我提供凭据时,会出现一个对话框。 但是,这在 PowerShell 远程会话中不起作用。 我必须在计算机上打开一个 RDP 会话。

如何让 git 从命令行请求凭据?

注意:我不想在某个文件中存储明文密码,也不想在命令行中输入明文密码。

【问题讨论】:

  • git credential fill 来自here?

标签: git command-line credentials


【解决方案1】:

安装Git Credential Manager for Windows
这也可以通过 Chocolatey 完成:

choco install git-credential-manager-for-windows

然后配置管理器从命令行询问密码:

git config --<system|global|local> credential.modalPrompt false

但是,根据this issue,它不能从命令行远程工作。

【讨论】:

  • 我可能弄错了,但我还是认为需要完全卸载win-manager才能恢复命令行提示符。
  • “credential-manager-for-windows”,抱歉缩短了。正如我所读到的,在安装 git 时有一个选项,您可以在其中取消选择它以不安装。但是在提到的文章stackoverflow.com/questions/37182847/…(这是StackOverflow上原始帖子的链接)中描述了一些卸载它的方法
【解决方案2】:

我认为您误认为 git 本身 在单独的 GUI 窗口中要求您提供凭据。 git 是一个仅限命令行的程序。然而,credentials 子系统又可以调用/调用一些外部程序来完成它的工作。

您需要检查您的 git 配置文件以找出调用了哪个程序并更改该设置。请参阅git doku on Credentials Storage 以供参考。不要误以为此帮助是关于密码存储的。您需要寻找的是禁用凭据帮助程序(在没有凭据帮助程序的情况下恢复默认行为)以获得您想要的。

这里是删除助手的方法:

git config --<system|global|local> --unset credential.helper

更多关于how to uninstall the credentials helper for windows

【讨论】:

  • 感谢您帮助我了解它的工作方式。您的解决方案在本地会话中没问题,但不幸的是在 PowerShell 远程会话中不起作用。
  • 有了你的回答和另一条评论,我提高了我的 git 知识,但我仍然需要 RDP 至少输入一次凭据...
猜你喜欢
  • 2018-10-21
  • 2015-10-17
  • 1970-01-01
  • 2019-12-08
  • 1970-01-01
  • 1970-01-01
  • 2018-06-06
  • 2020-07-22
  • 1970-01-01
相关资源
最近更新 更多