Git凭证填充拒绝我的输入(计划在Windows上进行) [英] Git credential fill rejects my input, scheduled on Windows

查看:63
本文介绍了Git凭证填充拒绝我的输入(计划在Windows上进行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows服务器上执行日常任务:git-pull +大量测试.

I want to run a daily task on a Windows server: git-pull + heavy tests.

由于我希望它由时间表触发并从脚本运行,因此我需要自动输入Git凭据.我想将 Git凭证填充与语法

As I want it to be triggered by a schedule and run from a script, I need the Git credentials to be fed in automatically. I want to use Git credential fill with the syntax key=value

由于这是我第一次使用Git凭据,所以我可能会遇到一些基本错误.

As this is my first time using Git credentials, I may got something basic wrong.

我尝试在Git Bash(Git扩展-> Ctrl + G )和Cygwin中工作.

I tried working in both Git Bash (Git extensions --> Ctrl + G) and Cygwin.

我在其中输入了以下几行:

There I entered the following lines:

$ git credential fill
protocol=ssh
host=devserver
username=<my user name>
password=<my password>
path=/srv/gitosis/repositories/Matlab.git
<empty line>

然后Git回复:

warning: invalid credential line:
fatal: unable to read credential from stdin

我还尝试只在空行之前输入一行,并得到相同的结果.我只尝试了用户名行,只尝试了协议行,并且只尝试了主机行.

I also tried to enter only a single line before the empty line and got the same result. I tried only username line, only protocol line, and only host line.

首先:我做错了什么?

第二个:正确的提要路径是什么?

Second: What is the correct path to feed?

如果我跑步

git remote -vv

并获得:

origin  gitosis@10.10.10.102:/srv/gitosis/repositories/Matlab.git (fetch)
origin  gitosis@10.10.10.102:/srv/gitosis/repositories/Matlab.git (push)

我走的路是什么?

第三:主机名是什么?

如果我运行 ping devserver ,请给出Git remote的输出并得到

Given the output of Git remote, if I run ping devserver and get

64 bytes from 10.10.10.102: icmp_seq=0 ttl=64 time=74 ms

这是否意味着主机是 devserver ?

推荐答案

首先,免责声明:我不知道Git的功能,我只是为了共同努力使它们工作,并在此发表评论对您有帮助.此时,我还使用了过时的Git版本(1.9.5.mysysgit;我有原因).

First, a disclaimer: I don't know the plumbing of Git, and I'm just hacking things together to make them work and commenting it here in case it is helpful to you. I'm also using an out-of-date version of Git at this point (1.9.5.mysysgit; I have reasons).

我从尝试做类似的事情中获得的经验是,git-credential很难正常工作.但是,通过更直接地使用凭证帮助程序,我确实获得了与工作类似的功能.

My experience from trying to do something similar has been that git-credential was difficult to get working correctly. I did, however, get something similar to work by operating using the credential helper more directly.

我找到了有关

I found an article about the credentials API that describes calling git credential-foo when git config credential.helper returns foo. This seems to have a slightly different interface, with the command get instead of fill (which also seems much more logical).

在任何情况下,对我而言,我的凭据助手都是 wincred ,我们将其称为主机 mysite.com .我的大部分工作都是在同一网站上进行的,因此Windows凭据管理器将为 https://myusername@mysite.com 而不是任何特定路径显示已保存的凭据.调用它,我输入:

In any case, for me, my credential helper is wincred, and let's call the host mysite.com. I do most of my work using the same site, so the Windows credential manager shows a saved credential for https://myusername@mysite.com, rather than to any specific path. Calling it, I enter:

>git credential-wincred get
protocol=https
host=mysite.com

然后离开:

username=myusername
password=mypassword

我还可以将用户名添加到输入列表中,并输出相同的内容.如果我在输入中添加了任何路径,或者用IP地址替换了主机,则无法使用.

I can also add a username to the input list, and it outputs the same thing. If I add any path to the inputs, or replace the host with the IP address, it doesn't work.

我的建议是查看是否可以使用 git credential-foo< get | store | erase> 语法而不是 git credential< fill | approve | reject> ,尽管它们看起来本质上是同一件事,只是名称略有不同.

My suggestion would be to see if you can use the git credential-foo <get|store|erase> syntax rather than git credential <fill|approve|reject>, though they appear to be in essence the same thing, just with slightly different names.

要回答您更具体的问题:

To answer your more specific questions:

我做错了什么?

假设我正确理解您正在尝试设置Git凭据,我想您想将 git凭据批准而不是 git凭据填充称为 approve 实际上会将您输入的值发送给帮助程序进行存储,而 fill 则试图填充您提供的数据中的空洞(我认为;这里和其他地方的命名在Git).

Assuming I understand correctly that you're trying to set the Git credentials, I think you want to call git credential approve rather than git credential fill, as approve will actually send your entered values to the helper for storage, whereas fill is attempting to fill in holes in the data you provided (I think; the naming here and elsewhere is confusing in Git).

正确的路径是什么?

What is the correct path to provide?

我不确定,因为我的一种重叠用法没有路径,但是我建议 srv/gitosis/repositories/Matlab.git ,因为斜杠由这就是路径.

I'm not sure, as my one overlapping usage didn't have a path, but I'd suggest srv/gitosis/repositories/Matlab.git, as the leading slash is implied by this being the path.

主机名是什么?

我怀疑这里发生的是在主机上以您的远程名称进行的简单字符串匹配,而不是对域的查找,因此我建议根据情况使用 host = 10.10.10.102

I suspect what's going on here is simple string matching on the host in your remote name, rather than a lookup of the domain, so I'd suggest using host=10.10.10.102 for your situation.

这篇关于Git凭证填充拒绝我的输入(计划在Windows上进行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆