简体   繁体   English

如何更改 Visual Studio 尝试推送的 GIT URL?

[英]How to change the GIT URL to which Visual Studio is trying to push?

The repo to which I need to push is this:我需要推送的回购是这样的:

https://myvault.visualstudio.com/foo/_versionControl?path=bar%2Fcxmlhub

But for some reason, VS is trying to push here:但出于某种原因,VS 试图推到这里:

https://myvault.visualstudio.com/foo/_versionControl?path=bar%2Fcxmlhub/info/refs&service=git-receive-pack

I don't know (and can't figure out) where the extra /info/refs&service=git-receive-pack is coming from.我不知道(也无法弄清楚)额外的/info/refs&service=git-receive-pack来自哪里。

When I do git remote -v I get back the correct URL for both fetch and push .当我执行git remote -v时,我会为fetchpush返回正确的 URL 。 Also, I am already logged in to the repo on a browser on the same machine.另外,我已经在同一台机器上的浏览器上登录了 repo。

This is the error I am seeing:这是我看到的错误:

Error encountered while pushing branch to the remote repository: Git failed with a fatal error.将分支推送到远程存储库时遇到错误:Git 失败并出现致命错误。 Unable to update url base from redirection无法从重定向更新 url 基础

I've looked at these two threads:我看过这两个线程:

git push gives fatal: unable to update url base from redirection: git 推送致命:无法从重定向更新 url 基础:

and

fatal: unable to update url base from redirection 致命:无法从重定向更新 url 基础

But they only tell me what I already know: I'm trying to push to the wrong URL.但他们只告诉我我已经知道的:我试图推错 URL。 What I don't know is how to fix this!我不知道如何解决这个问题!

Your remote URL is misconfigured.您的遥控器 URL 配置错误。 Git doesn't allow repository URLs to contain query strings. Git 不允许存储库 URL 包含查询字符串。

The reason you're seeing the extra /info/refs&service=git-receive-pack is because that's the portion of the URL that Git adds onto the base remote URL you give it in order to discover references.您看到额外的/info/refs&service=git-receive-pack的原因是因为这是 Git 添加到基本远程 ZE6B391A8D2C4C455503DZ 参考的 URL 的一部分,您按顺序将其添加到基础远程 ZE6B391A8D2C4D45902A23A 中。 If you're trying to push, Git needs to determine what the remote side has, and reading references is the first step in that process.如果您尝试推送,Git 需要确定远程端有什么,读取引用是该过程的第一步。

Your URL should likely be https://myvault.visualstudio.com/foo/_versionControl instead, and you can modify it by using git remote set-url origin https://myvault.visualstudio.com/foo/_versionControl (assuming your remote name is origin ). Your URL should likely be https://myvault.visualstudio.com/foo/_versionControl instead, and you can modify it by using git remote set-url origin https://myvault.visualstudio.com/foo/_versionControl (assuming your remote名字是origin )。 If that's not correct for your case, open the web page up in a browser and find the clone URL in the web interface, and then use that instead.如果这不适合您的情况,请在浏览器中打开 web 页面,然后在 web 界面中找到克隆 URL,然后使用它。

If you're trying to push to a subdirectory of the remote repository, know that that isn't possible.如果您尝试推送到远程存储库的子目录,请知道这是不可能的。 Git doesn't allow pushing into only a subdirectory of repositories. Git 不允许只推入存储库的子目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM