【问题标题】:Git clone from TFS error: RPC failed; result=22, HTTP code = 401来自 TFS 错误的 Git 克隆:RPC 失败;结果 = 22,HTTP 代码 = 401
【发布时间】:2024-05-01 09:05:03
【问题描述】:

我目前正在尝试在我的 Mac 上从 TFS 克隆存储库,但出现以下错误:

$ git clone https://tfs.xx.com/yy/_git/Mobile
Cloning into 'Mobile'...
Username for 'https://tfs.xx.com': xxx
Password for 'https://xxx@tfs.xx.com': 
error: RPC failed; result=22, HTTP code = 401
fatal: The remote end hung up unexpectedly

环境:

  • Mac OS X EI Captian 版本 10.11.1
  • Git 2.3.8 (Apple Git-58)
  • TFS 2015

谷歌搜索了几种可能的解决方案,但都失败了。

  1. 增加 http post 缓冲区

    git config --global http.postBuffer 524288000

  2. 在安全钥匙串中缓存凭据

    git config --global credential.helper osxkeychain

  3. 升级git到最新版本v2.6.4(失败后卸载)

我怀疑根本情况可能是 TFS 服务器上的身份验证配置。不基于窗口 NTLM 的 TFS 服务器阻止访问。这么说,我的证据是当我使用 GIT_CURL_VERBOSE=1 运行 git 时。它在日志末尾显示了更多详细信息。有消息:

* NTLM handshake rejected
* Authentication problem. Ignoring this.

Mac 上的部分详细日志:

$ GIT_CURL_VERBOSE=1 git clone https://tfs.xx.com/yy/_git/Mobile
Cloning into 'Mobile'...
...................
* upload completely sent off: 154 out of 154 bytes
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html
< Server: Microsoft-IIS/8.0
< X-TFS-ProcessId: f00df4b5-6907-4ccd-818c-773f01ee3961
< X-FRAME-OPTIONS: SAMEORIGIN
< Access-Control-Allow-Origin: *
< Access-Control-Max-Age: 3600
< Access-Control-Allow-Methods: OPTIONS,GET,POST,PATCH,PUT,DELETE
< Access-Control-Expose-Headers: ActivityId,X-TFS-Session
< Access-Control-Allow-Headers: authorization
< Set-Cookie: Tfs-SessionId=d13bcac7-856f-4435-b94b-b2f2d24b2dd1; path=/
< Set-Cookie: Tfs-SessionActive=2016-01-13T06:01:32; path=/
* NTLM handshake rejected
* Authentication problem. Ignoring this.
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
< X-Content-Type-Options: nosniff
< Date: Wed, 13 Jan 2016 06:01:31 GMT
< Content-Length: 842
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Age: 1
< Connection: keep-alive
< Via: 1.1 akamai (ACE 5.4.0/5.4.0)
* The requested URL returned error: 401
* Closing connection 1
error: RPC failed; result=22, HTTP code = 401
fatal: The remote end hung up unexpectedly

好吧,当我在 Windows 上调用相同的命令时。它执行正确。不同的是windows显示的是:

* NTLM auth restarted

然后继续。 Mac 回应时:

* NTLM handshake rejected
* Authentication problem. Ignoring this

然后停止。

windows上的部分详细日志

$ GIT_CURL_VERBOSE=1 git clone https://tfs.xx.com/yy/_git/Mobile
Cloning into 'Mobile'...
...................
* upload completely sent off: 154 out of 154 bytes
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html
< Server: Microsoft-IIS/8.0
< X-TFS-ProcessId: f00df4b5-6907-4ccd-818c-773f01ee3961
< X-FRAME-OPTIONS: SAMEORIGIN
< Access-Control-Allow-Origin: *
< Access-Control-Max-Age: 3600
< Access-Control-Allow-Methods: OPTIONS,GET,POST,PATCH,PUT,DELETE
< Access-Control-Expose-Headers: ActivityId,X-TFS-Session
< Access-Control-Allow-Headers: authorization
< Set-Cookie: Tfs-SessionId=544cda47-3165-4087-ac40-324936afcb41; path=/
< Set-Cookie: Tfs-SessionActive=2016-01-13T07:30:30; path=/
* NTLM auth restarted
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
< X-Content-Type-Options: nosniff
< Date: Wed, 13 Jan 2016 07:30:30 GMT
< Content-Length: 842
< Vary: Accept-Encoding
< Content-Encoding: gzip
< Age: 0
< Connection: keep-alive
< Via: 1.1 akamai (ACE 5.4.0/5.4.0)
<
* Ignoring the response-body
* Connection #1 to host tfs.xx.com left intact
* Issue another request to this URL: 'https://tfs.xx.com/yy/_git/Mobile/git-upload-pack'
* Couldn't find host tfs.xx.com in the _netrc file; using defaults
* Found bundle for host tfs.xx.com: 0x5a0b70
* Re-using existing connection! (#1) with host tfs.xx.com
* Connected to tfs.xx.com (199.6.147.240) port 443 (#1)
* Server auth using NTLM with user 'szhao8'
> POST /yy/_git/Mobile/git-upload-pack HTTP/1.1
Host: tfs.xx.com
Authorization: NTLM *************************************************==
User-Agent: git/2.6.4.windows.1
Accept-Encoding: gzip
Content-Type: application/x-git-upload-pack-request
Accept: application/x-git-upload-pack-result
Content-Length: 0
...................
<
remote:
remote:                    fTfs
remote:                  fSSSSSSSs
remote:                fSSSSSSSSSS
remote: TSSf         fSSSSSSSSSSSS
remote: SSSSSF     fSSSSSSST SSSSS
remote: SSfSSSSSsfSSSSSSSt   SSSSS
remote: SS  tSSSSSSSSSs      SSSSS
remote: SS   fSSSSSSST       SSSSS
remote: SS fSSSSSFSSSSSSf    SSSSS
remote: SSSSSST    FSSSSSSFt SSSSS
remote: SSSSt        FSSSSSSSSSSSS
remote:                FSSSSSSSSSS
remote:                  FSSSSSSs
remote:                    FSFs    (TM)
remote:
remote:  Microsoft (R) Visual Studio (R) Team Foundation Server
remote:
* Connection #1 to host tfs.xx.com left intact| 5.52 MiB/s
Receiving objects: 100% (5768/5768), 31.25 MiB | 5.98 MiB/s, done.
Resolving deltas: 100% (3937/3937), done.
Checking connectivity... done.
Checking out files: 100% (1005/1005), done.

以前有人遇到过这个问题吗?感谢您的反馈!

【问题讨论】:

  • 有些时候网速慢会出现这个问题。
  • 感谢您的提醒!网络速度非常慢。我会尝试更好的网络环境。
  • @anandmishra 你是对的。好像是网速慢的缘故。今天又能正常使用了。

标签: git macos tfs


【解决方案1】:

有时会因为网速慢而出现此问题。请尝试以更好的网络速度克隆存储库。

【讨论】:

    最近更新 更多