git provider 错误中不支持的 URL 协议
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38602178/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unsupported URL protocol in git provider error
提问by s952163
I have two separate PCs that connect to the same Gitlab repo. Both running Visual Studio Update 3 and using Team Explorer with Git. On one PC, I have no problem updating the project and then pushing the commits to the remote repo. On the other PC however any operation (push or fetch or sync) will fail with an Unsupported URL protocol
error, although originally I managed to clone the repo. I suspect it doesn't like something in the connection string, since I can commit and sync the repo using command line git (version 2.9.2 so fairly recent). What is the cause of this error and is there a workaround?
我有两台单独的 PC 连接到同一个 Gitlab 存储库。运行 Visual Studio Update 3 和使用带有 Git 的团队资源管理器。在一台 PC 上,更新项目然后将提交推送到远程存储库没有问题。然而,在另一台 PC 上,任何操作(推送或获取或同步)都将失败并显示Unsupported URL protocol
错误,尽管最初我设法克隆了 repo。我怀疑它不喜欢连接字符串中的某些内容,因为我可以使用命令行 git(版本 2.9.2 相当新)提交和同步 repo。此错误的原因是什么,是否有解决方法?
回答by s952163
I have checked the difference between the two local repos, and git remote -v
on PC1 gives:
我检查了两个本地存储库之间的差异,并git remote -v
在 PC1 上给出:
origin https://gitlab.com/...
来源https://gitlab.com/...
while on PC2:
在 PC2 上时:
origin [email protected]: ...
来源 [email protected]: ...
After further investigation it appears that the old version of LibGit2which VS2015 Update3 uses lacks SSH support. The first repo was the original and created in VS, the second repo was cloned via a command-line, hence the SSH connection string.
经过进一步调查,VS2015 Update3 使用的旧版本LibGit2似乎缺乏 SSH 支持。第一个存储库是在 VS 中创建的原始存储库,第二个存储库是通过命令行克隆的,因此是 SSH 连接字符串。
The workaround is to change the connection string in .git/config
to
解决方法是将连接字符串更改.git/config
为
url = https://gitlab.com/...
网址 = https://gitlab.com/...
If one absolutely needs SSH than it is possible to recompile gitlib2, or use command line git which works. It might be possible to use other Git Source Providers in VS2015, however I haven't tested it. (for example Git Source Control Provider 2015)
如果绝对需要 SSH,则可以重新编译 gitlib2,或使用有效的命令行 git。在 VS2015 中可能可以使用其他 Git 源提供程序,但是我还没有测试过。(例如Git Source Control Provider 2015)