git拒绝通过http发送凭据?

curl似乎工作正常,但git没有。 git要求input密码,但是不会发送任何凭据。

作品: curl --netrc http://test.git.unsw.edu.au/curl -u username:password http://test.git.unsw.edu.au/

不起作用: git remote update

 Password for 'http://[email protected]': * Couldn't find host test.git.unsw.edu.au in the .netrc file; using defaults User-Agent: git/1.7.9.5 Host: test.git.unsw.edu.au Accept: */* Pragma: no-cache 

为什么不是git发送凭据?

从一个strace,我看到:

  1. 阅读.netrc
  2. GET /repo/info/refs?service=git-receive-pack HTTP/1.1 – 没有证书
  3. HTTP/1.0 401 Unauthorized
  4. 阅读.netrc
  5. GET /repo/info/refs?service=git-receive-pack HTTP/1.0 – 无凭据
  6. HTTP/1.0 401 Unauthorized
  7. 提示input密码
  8. 阅读.netrc
  9. * Couldn't find host test.git.unsw.edu.au in the .netrc file; using defaults
  10. GET /repo/info/refs?service=git-receive-pack HTTP/1.1 – 没有证书
  11. HTTP/1.0 401 Unauthorized

看看手册页,似乎git不使用用户名选项时使用http。 但是,如果你把它放在你的.netrc文件中,curl应该使用它。 .netrc的格式是

 machine hostname login yourusername password yourpassword 

混帐似乎只使用CURLAUTH_ANY这不适用于我的特定Web服务器。 我的Web服务器支持NegotiateBasic所以当Negotiate在客户端上不可用时,git不会回退到Basic 。 此外,似乎没有选项可以使用除CURLAUTH_ANY其他任何东西。