使用 Visual Studio 2017 克隆 TFS Git 存储库时出现错误 400
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42721469/
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
Error 400 when cloning TFS Git repo using Visual Studio 2017
提问by Steve Kennedy
In Visual Studio 2017, when I attempt to connect to an existing on-premise TFS 2015 team project, and attempt to clone an existing Git repo using Team Explorer (by clicking the Clone button after highlighting the the repo name in the Connect to a Project modal), I get error message saying
在 Visual Studio 2017 中,当我尝试连接到现有的内部部署 TFS 2015 团队项目,并尝试使用团队资源管理器克隆现有的 Git 存储库时(通过在“连接到项目”中突出显示存储库名称后单击“克隆”按钮) modal),我收到错误消息说
Git failed with a fatal error. fatal: unable to access 'https://servername:8080/tfs/TeamProjects Collection/ProjectName/_git/RepoName/': The requested URL returned error: 400
Git 因致命错误而失败。致命:无法访问“ https://servername:8080/tfs/TeamProjects Collection/ProjectName/_git/RepoName/”:请求的 URL 返回错误:400
I also get this error showing up in my output window.
我的输出窗口中也显示了此错误。
回答by Steve Kennedy
UPDATE:It does appear that Microsoft has fixed this issue in an update to Visual Studio 2017. Most likely, Update 3 as mentioned in comment below. If you're not using at least Update 3, this answer may pertain to you still, as people were reporting this issue even with version 15.8.5.
更新:微软似乎已经在 Visual Studio 2017 的更新中修复了这个问题。很可能是下面评论中提到的更新 3。如果您至少没有使用 Update 3,那么这个答案可能仍然适用于您,因为即使使用 15.8.5 版本,人们也会报告此问题。
This is primarily because Visual Studio 2017 is mishandling spaces in the Team Project Collection name. It does not encode them to use %20 for spaces. Here's steps to work around.
这主要是因为Visual Studio 2017 对 Team Project Collection name 中的空格处理不当。它不会对它们进行编码以使用 %20 作为空格。以下是解决的步骤。
Click Cancel button to close the "Connect to a Project" window.
单击取消按钮关闭“连接到项目”窗口。
In Team Explorer, underneath the Clone Repository section, notice how the top box does have spaces in the URL. Cancel the clone by clicking the Cancel link. Do this, because you'll find that you cannot edit the Clone Repository inputs.
在 Team Explorer 中,在 Clone Repository 部分下方,注意顶部框中的 URL 中有空格。通过单击取消链接取消克隆。这样做,因为您会发现您无法编辑 Clone Repository 输入。
Then, click the Clone Repository link in the Projectsection of the Team Explorer window.
然后,单击Team Explorer 窗口的Project部分中的 Clone Repository 链接。
You'll notice the Clone Repository section will reappear, but now will not be editable. Notice that the first/top input box has replaced any spaces in the URL with %20. Ensure that you're second box, which maps a local path to download your source to, is accurate. Click Clone button, and it should work.
您会注意到克隆存储库部分将重新出现,但现在不可编辑。请注意,第一个/顶部输入框已将 URL 中的所有空格替换为 %20。确保您是第二个框,它映射了要将源下载到的本地路径,是准确的。单击克隆按钮,它应该可以工作。
回答by Ben Pittoors
I can confirm it is still (or again) broken in version 15.8.1.
我可以确认它在 15.8.1 版本中仍然(或再次)被破坏。
But I found another workaround:
但我找到了另一种解决方法:
- use a browser to navigate to the 'Code' repository in vsts
- click on the 'Clone' button (icon)
- select IDE 'Clone in Visual Studio'
- allow the link to open VS 2017 and it will pass along the correct url encoded location
- 使用浏览器导航到 vsts 中的“代码”存储库
- 单击“克隆”按钮(图标)
- 选择 IDE 'Clone in Visual Studio'
- 允许链接打开 VS 2017,它将传递正确的 url 编码位置
回答by Igand
I encoutered this issue again now, year after fix was released, in VS 15.6.6. Enterprise. When trying to connect to a project with space in the name, VS kept messing up the URL and therefore didn't find the project.
在 VS 15.6.6 修复发布一年后,我再次遇到了这个问题。企业。当尝试连接到名称中有空格的项目时,VS 不断弄乱 URL,因此没有找到该项目。
Steve Kennedy's solution is no longer possible - MS actually fixed that \O/.
史蒂夫肯尼迪的解决方案不再可能 - MS 实际上修复了\O/。
In the end I copied complete working projectfrom a collegue so that I'd get configs with correct URL. Everything worked fine.
最后,我从一位同事那里复制了完整的工作项目,以便获得具有正确 URL 的配置。一切正常。
Just so you know, there is this solution as well.
只是你知道,也有这个解决方案。