【问题标题】:Cannot access git remote branches with shell but can with GitHub Desktop无法使用 shell 访问 git 远程分支,但可以使用 GitHub Desktop
【发布时间】:2021-02-10 16:33:10
【问题描述】:

我遇到了以前从未遇到过的 Git 问题。 我现在正在使用 Azure Dev Ops 将内容推送到 Git 存储库。 我以前从未使用过它,所以请认为我是一个完全的菜鸟。

我需要连接到 VPN 才能访问 Azure Dev Ops。 我无法访问远程服务器,这意味着我无法使用 shell(我喜欢在 UI 上使用)获取、拉取或推送。 每次我尝试获取(连接我的 vpn)时都会收到以下错误:

致命:无法访问“https://companyname@dev.azure.com/companyname/groupname/_git/reponame/”:无法连接到 dev.azure.com 端口 443:连接被拒绝

当我尝试在没有 vpn 的情况下进行获取时。我得到凭据管理器窗口,询问我的帐户登录名和密码,但由于 VPN 未连接,它无法通过身份验证。

现在,事情开始变得复杂了。 到目前为止,我已经成功地工作了,因为我可以使用 GitHub 桌面应用程序获取、拉取和推送。 它是唯一有效的 UI。我试过其他的,但这是唯一一个设法从远程获取的。

我查看了应用程序日志,一点击“获取”按钮就看到了这个命令:

git -c credential.helper= fetch --progress --prune origin

虽然,此命令在 shell 中不起作用。 我得到同样的错误:

致命:无法访问“https://companyname@dev.azure.com/companyname/groupname/_git/reponame/”:无法连接到 dev.azure.com 端口 443:连接被拒绝

这是我的配置(git config --list):

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
credential.helper=
credential.helper=C:/Program\ Files\ \(x86\)/Git\ Credential\ Manager\ Core/git-credential-manager-core.exe
credential.https://dev.azure.com.usehttppath=true
user.username=My Username
user.name=My Name
user.email=My work email (and email used in my azure account)
commit.template=C:/Users/name/Documents/git_message.txt
alias.st=status
alias.ci=commit
alias.lg=log --graph --date=relative --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ad)%Creset'
alias.oops=commit --amend --no-edit
alias.review-local=!git lg @{push}..
alias.li=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
alias.lol=log --graph --decorate --pretty=oneline --abbrev-commit
alias.lola=log --graph --decorate --pretty=oneline --abbrev-commit --all
alias.pullall=fetch --all && pull
alias.fp=fetch --prune
alias.ba=branch -a
gui.recentrepo=C:/Users/name/Documents/Workspace_companyname/projectname
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
submodule.active=.
remote.origin.url=https://companyname@dev.azure.com/companyname/groupname/_git/reponame
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

有人知道是什么导致了这个问题吗?

提前感谢您的帮助。

【问题讨论】:

    标签: git azure-devops


    【解决方案1】:

    您可以尝试以下可能的解决方案来解决此问题。

    1、运行以下命令配置git的代理设置。

    git config --global http.proxy https://user:password@proxy.com:port

    然后在本地机器上创建一个环境变量HTTP_PROXY。并将其值设置为https://:@proxy:port

    请参阅this threadhere 了解更多信息。

    2,您也可以尝试以下解决方案,修改 git 配置文件以在远程 url 中包含凭据:

    将您的companyname 替换为personal access token

    remote.origin.url=https://PersonalAccessToken@dev.azure.com/companyname/groupname/_git/reponame

    git remote add origin -f  "https://PersonalAccessToken@dev.azure.com/companyname/groupname/_git/reponame"
    

    3,您也可以尝试使用 SSH 连接到您的 azure devops git。

    请查看以下文档了解更多信息。

    Use SSH key authentication

    【讨论】:

    • 我在第一个解决方案中设置代理时收到以下消息:致命:无法访问'companyname@dev.azure.com/companyname/groupname/_git/reponame':错误设置证书验证位置:CAfile:C:/Program Files/Git/ mingw64/libexec/ssl/certs/ca-bundle.crt CApath:无
    • 使用第二种解决方案。我得到和以前一样的错误。 SSH 实际上是我尝试过的第一件事,但即使我在 Azure Dev Ops 中设置了我的 SSH 公钥,每次连接都被拒绝。
    猜你喜欢
    • 1970-01-01
    • 2021-05-27
    • 2019-11-21
    • 2020-04-03
    • 1970-01-01
    • 1970-01-01
    • 2013-01-07
    • 2016-02-01
    • 1970-01-01
    相关资源
    最近更新 更多