[英]Git Credential Helper on Windows without asking for credentials
Is there a way to run the Git Credential helper on Windows without asking for username/password if there is no stored information? 如果没有存储的信息,是否可以在Windows上运行Git凭据帮助程序而无需询问用户名/密码?
The git credential
command provides the fill
command, allowing to retrieve credentials for a Git repo. git credential
命令提供fill
命令,允许检索Git存储库的凭据。 If there is stored credential information, it prints it to stdout
. 如果存储了凭证信息,则将其打印到
stdout
。
If there is no stored information for the requested repo, it opens a prompt or Windows dialog to ask for the credentials. 如果没有用于请求的存储库的已存储信息,它将打开提示或Windows对话框,要求提供凭据。 Can this be avoided?
可以避免吗?
To replicate: 复制:
git credential fill
and then enter the following in the command window: git credential fill
,然后在命令窗口中输入以下内容: url=http://foo [ENTER] [ENTER]
Make sure to end with two blank lines to tell the credential helper that your input is finished. 确保以两个空行结束,以告知凭据帮助者您的输入已完成。
Since the Git credential helper shouldn't have any stored information for this repo, it will prompt you for your credentials. 由于Git凭证帮助程序不应该为此回购存储任何信息,因此它将提示您输入凭证。 On Windows, this is done using a system credential dialog (similar to the login dialog).
在Windows上,这是使用系统凭据对话框(类似于登录对话框)完成的。
Is there a way to avoid this prompt? 有办法避免这种提示吗? What I'm looking for is something like a return code indicating that there was no stored information for the requested repo.
我正在寻找的是类似返回码的内容,指示没有存储用于请求的回购的信息。 At the moment, this doesn't seem to be possible, the credential helper always asks for the credentials.
目前,这似乎是不可能的,凭证助手总是要求提供凭证。
There doesn't seem a way to avoid that prompt for credentials. 似乎没有办法避免提示输入凭据。
I usually use a different credential helper, based on an gpg-encrypted .netrc
(or _netrc
on Windows) and the official contrib/credential/netrc/test.netrc
perl script, which I modify a bit . 我通常基于gpg加密的
.netrc
(或Windows上的_netrc
)和官方的contrib/credential/netrc/test.netrc
perl脚本使用不同的凭据帮助器,对此我做了一些修改 。
That way, I only have to enter one password during the session, and all the different credentials stored in the encrypted .netrc
are available for all the site. 这样,我只需要在会话期间输入一个密码,并且存储在加密的
.netrc
中的所有不同凭据就可用于所有站点。
Since there is a gpg agent running, I don't have to enter that same password during the current session. 由于有一个gpg代理正在运行,因此我在当前会话期间不必输入相同的密码。
I use that same script to check if a site has credential information or not with: 我使用相同的脚本通过以下方法检查网站是否具有凭据信息:
echo host=a.site.com | ./git-credential-netrc -f path/to/.netrc.asc get
The ' get
' command should be respected by any git credential helper, so check if a similar command would work with git-credential-winstore
command. 任何git凭证帮助程序都应遵守'
get
'命令,因此请检查git-credential-winstore
命令是否可以使用类似的命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.