GIT 错误:致命:无法访问“https://dev.azure.com/****/”:接收失败:克隆时连接已重置

问题描述 投票:0回答:2

克隆存储库,通过 VSCODE、GITExtensions、GIT BASH 使用 git 从 Azure Devops 推送、获取和拉取代码会导致大约 80% 的时间出现“致命无法访问”和“连接已重置”错误。有时它会起作用,并且在发送“git push”命令时它会起作用 20 次中有 1 次,但它是随机的。

我需要帮助来解决这个“连接已重置”,因为我无法为我的客户工作。

更多信息请参考:https://github.com/git-ecosystem/git-credential-manager/issues/1150 我也已经在这里解释了信息

附加日志(已删除):

Diagnose log at 2023-03-14T09:30:54Z

AppPath: C:\Program Files\Git\mingw64\bin\git-credential-manager-core.exe
InstallDir: C:\Program Files\Git\mingw64\bin\
Version: 2.0.886+ea93cb5158

------------
Diagnostic: Environment
Skipped: False
Success: True
Exception: None
Log:
OSType: Windows
OSVersion: 10.0 (build 22621)
Reading environment variables... OK
 Variables:
HOMEPATH=\Users\eerae
DriverData=C:\Windows\System32\Drivers\DriverData
COMPUTERNAME=ESECONSULTING
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
OneDrive=C:\Users\eerae\OneDrive
TMP=C:\Users\eerae\AppData\Local\Temp
HOME=C:\Users\eerae
PROCESSOR_REVISION=9a03
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core
TEMP=C:\Users\eerae\AppData\Local\Temp
LOCALAPPDATA=C:\Users\eerae\AppData\Local
MSYSTEM=MINGW64
TERM=xterm-256color
COLORTERM=truecolor
USERDOMAIN=ESECONSULTING
ProgramFiles(x86)=C:\Program Files (x86)
Path=C:/Program Files/Git/mingw64/libexec/git-core;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\eerae\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files (x86)\GitExtensions\;C:\Users\eerae\AppData\Local\Microsoft\WindowsApps;;C:\Users\eerae\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\eerae\.dotnet\tools
PROCESSOR_LEVEL=6
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 154 Stepping 3, GenuineIntel
TMPDIR=C:\Users\eerae\AppData\Local\Temp
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
NUMBER_OF_PROCESSORS=20
CommonProgramFiles=C:\Program Files (x86)\Common Files
PLINK_PROTOCOL=ssh
ProgramData=C:\ProgramData
ProgramW6432=C:\Program Files
ProgramFiles=C:\Program Files (x86)
SystemRoot=C:\Windows
SESSIONNAME=Console
LC_CTYPE=C.UTF-8
CommonProgramW6432=C:\Program Files\Common Files
ZES_ENABLE_SYSMAN=1
LOGONSERVER=\\ESECONSULTING
USERPROFILE=C:\Users\eerae
USERDOMAIN_ROAMINGPROFILE=ESECONSULTING
APPDATA=C:\Users\eerae\AppData\Roaming
HOMEDRIVE=C:
EXEPATH=C:\Program Files\Git
USERNAME=eerae
PROCESSOR_ARCHITEW6432=AMD64
PROCESSOR_ARCHITECTURE=x86
OS=Windows_NT
ComSpec=C:\Windows\system32\cmd.exe
SystemDrive=C:
windir=C:\Windows
OneDriveConsumer=C:\Users\eerae\OneDrive
ALLUSERSPROFILE=C:\ProgramData


------------
Diagnostic: File system
Skipped: False
Success: True
Exception: None
Log:
Temporary directory is 'C:\Users\eerae\AppData\Local\Temp\'...
Checking basic file I/O...
Writing to temporary file 'C:\Users\eerae\AppData\Local\Temp\a34f41c181a0608037415d3a'... OK
Reading from temporary file 'C:\Users\eerae\AppData\Local\Temp\a34f41c181a0608037415d3a'... OK
Deleting temporary file 'C:\Users\eerae\AppData\Local\Temp\a34f41c181a0608037415d3a'... OK
Testing IFileSystem instance...
UserHomePath: C:\Users\eerae
UserDataDirectoryPath: C:\Users\eerae\.gcm
GetCurrentDirectory(): C:\Work\Repos

------------
Diagnostic: Networking
Skipped: False
Success: True
Exception: None
Log:
Checking networking and HTTP stack...
Creating HTTP client... OK
IsNetworkAvailable: True
Sending HEAD request to http://example.com... OK
Sending HEAD request to https://example.com... OK
Acquiring free TCP port... OK
Testing local HTTP loopback connections...
Creating new HTTP listener for http://localhost:58764/... OK
Waiting for loopback connection... OK
Writing response... OK
Waiting for response data... OK
Loopback connection data OK

------------
Diagnostic: Git
Skipped: False
Success: True
Exception: None
Log:
Getting Git version... OK
Git version is '2.39.2.windows.1'
Locating current repository... OK
Not inside a Git repository.
Listing all Git configuration... OK
Git configuration:
file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain
file:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=git-lfs clean -- %f
file:C:/Program Files/Git/etc/gitconfig filter.lfs.smudge=git-lfs smudge -- %f
file:C:/Program Files/Git/etc/gitconfig filter.lfs.process=git-lfs filter-process
file:C:/Program Files/Git/etc/gitconfig filter.lfs.required=true
file:C:/Program Files/Git/etc/gitconfig http.sslbackend=openssl
file:C:/Program Files/Git/etc/gitconfig http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true
file:C:/Program Files/Git/etc/gitconfig core.fscache=true
file:C:/Program Files/Git/etc/gitconfig core.symlinks=false
file:C:/Program Files/Git/etc/gitconfig pull.rebase=false
file:C:/Program Files/Git/etc/gitconfig credential.helper=manager
file:C:/Program Files/Git/etc/gitconfig credential.https://dev.azure.com.usehttppath=true
file:C:/Program Files/Git/etc/gitconfig init.defaultbranch=master
file:C:/Users/eerae/.gitconfig  core.editor="C:/Users/eerae/AppData/Local/Programs/Microsoft VS Code/bin/code" --wait
file:C:/Users/eerae/.gitconfig  core.compression=0
file:C:/Users/eerae/.gitconfig  user.name=Senne Eeraerts
file:C:/Users/eerae/.gitconfig  user.email=**@***.com
file:C:/Users/eerae/.gitconfig  user.password=***.
file:C:/Users/eerae/.gitconfig  https.postbuffer=1048576000
file:C:/Users/eerae/.gitconfig  merge.guitool=vscode
file:C:/Users/eerae/.gitconfig  mergetool.vscode.path=C:/Users/eerae/AppData/Local/Programs/Microsoft VS Code/Code.exe
file:C:/Users/eerae/.gitconfig  mergetool.vscode.cmd="C:/Users/eerae/AppData/Local/Programs/Microsoft VS Code/Code.exe" --wait --merge "$REMOTE" "$LOCAL" "$BASE" "$MERGED"
file:C:/Users/eerae/.gitconfig  pull.rebase=false
file:C:/Users/eerae/.gitconfig  fetch.prune=false
file:C:/Users/eerae/.gitconfig  rebase.autostash=false
file:C:/Users/eerae/.gitconfig  rebase.autosquash=false
file:C:/Users/eerae/.gitconfig  rebase.updaterefs=false
file:C:/Users/eerae/.gitconfig  diff.guitool=vscode
file:C:/Users/eerae/.gitconfig  difftool.vscode.path=C:/Users/eerae/AppData/Local/Programs/Microsoft VS Code/Code.exe
file:C:/Users/eerae/.gitconfig  difftool.vscode.cmd="C:/Users/eerae/AppData/Local/Programs/Microsoft VS Code/Code.exe" --wait --diff "$LOCAL" "$REMOTE"
file:C:/Users/eerae/.gitconfig  http.sslverify=true
file:C:/Users/eerae/.gitconfig  http.postbuffer=524288000
file:C:/Users/eerae/.gitconfig  gui.recentrepo=C:/Work/Repos/Integration/Integration
file:C:/Users/eerae/.gitconfig  credential.helper=store


------------
Diagnostic: Credential storage
Skipped: False
Success: True
Exception: None
Log:
ICredentialStore instance is of type: CredentialStore
Writing test credential... OK
Reading test credential... OK
Deleting test credential... OK

------------
Diagnostic: Microsoft authentication (AAD/MSA)
Skipped: False
Success: True
Exception: None
Log:
Broker not supported.
Flow type is: Auto
Gathering MSAL token cache data... OK
CacheDirectory: C:\Users\eerae\AppData\Local\.IdentityService
CacheFileName: msal.cache
CacheFilePath: C:\Users\eerae\AppData\Local\.IdentityService\msal.cache
Creating cache helper... OK
Verifying MSAL token cache persistence... OK

------------
Diagnostic: GitHub API
Skipped: False
Success: True
Exception: None
Log:
Using 'https://github.com/' as API target.
Querying '/meta' endpoint... OK

截图: Git Clone via CMD VSCODE Issue

我认为这个问题可能与互联网问题有关,但是从同一网络上的另一台计算机再次克隆可以按预期工作。

我尝试过的事情:

  • 重置我的密码 - 不成功
  • 在 Windows 凭据管理器中删除 GIT 凭据 - 这允许我重新输入我的密码(与用于登录 azure devops 的密码相同)并且仅成功克隆/推送一次,之后它再次失败。
  • 重新安装 GIT,不要安装 GIT Credential manager
  • 只需在 vscode 中发送“推送”和“同步更改”按钮就可以奇迹般地工作 30 次中的 1 次。
  • 有时,如果我在本地设备上删除我的 GIT 凭据,系统会提示我再次添加密码(VSCODE 和 GIT 都会提示我),在提供我的密码和我的 2-Factor Authenticator 之后,我会遇到“无法访问”的问题和一个致命错误。
  • 刷新 DNS
  • 从另一台计算机克隆(工作正常) ** 请注意,在 1.5 周内,使用我的客户提供给我的电子邮件地址推送和克隆回购没有任何问题,浏览浏览器并在 devops 本身上编辑代码(仍然)工作正常。到家一天突然出现这个错误**
git azure command-line-interface git-clone
2个回答
0
投票

我遇到了完全相同的问题。在某些时候它完全停止工作。

所以我最终使用 SSH 克隆了我的 repo。为此,您需要配置 SSH 密钥。在克隆存储库中选择 SSH,然后管理 SSH 密钥。

检查此链接以获得创建 SSH 密钥的帮助。

https://learn.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops

它说你使用 ssh-keygen 来生成你的密钥。我可以在命令提示符下运行该命令。我不知道是否每个人都可以,或者我之前只是安装了一些东西。无论如何,您可以使用其他工具生成该密钥,例如 PuttyGen。

完成后,只需使用 [email protected]:v3/organization/project/repo 克隆您的存储库,您可以从“克隆存储库”屏幕复制它。

备注:

  • 在更改为 ssh 之前,我的解决方法是连接到 VPN(work vpn 或 kaspersky vpn)。这工作了几个月。
  • 升级到 Windows 11 无效,无需尝试。
  • 我还没有安装新的 Windows 副本。所以我不知道这是否行得通。

(编辑)

  • 我卸载了防病毒软件,并禁用了 Windows 防火墙。还是行不通。但是 VPN 解决方法再次起作用,即使在重新安装之后也是如此。还在用ssh。

0
投票

我在您的问题或问题中没有看到的一项工作是token

Azure(或 GitHub)的 HTTPS URL 应该用作密码PAT个人访问令牌

对于 Azure 访问:“使用个人访问令牌”。

假设

C:\Program Files\Git\usr\bin
C:\Program Files\Git\mingw64\bin
在你的
%PATH%
中:

  • 检查您的凭证助手:它应该是“

    manager
    ”(或
    manager-core
    ):

    git config --global credential.helper
    
  • 检查您是否已经缓存了任何凭据(来自简单的 CMD):

    printf "host= dev.azure.com\nprotocol=https\nusername=YOU" | git credential-manager get
    

    用您的 Azure 登录帐户名替换“

    YOU

  • 如果您看到的是空的或不是您的代币,请注册:

    printf "host= dev.azure.com\nprotocol=https\nusername=YOU" | git credential-manager store YOUR_TOKEN
    

然后再次尝试您的 HTTPS 访问(推/拉/获取)


注:紧随其后的是

git-ecosystem/git-credential-manager
issue 1150,其中包括:

对于任何想要摆脱这个恼人问题的人,需要禁用 IPv6

© www.soinside.com 2019 - 2024. All rights reserved.