Visual Studio/GIT:没有跟踪远程分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40547932/
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
Visual studio/GIT : No tracked remote branch
提问by Hermios
I just configured Visual Studio 2015 with a connection to GitHub. Unfortunately, it doesn't work to track the remote branch. I have 2 projects in the same solution, each has its own repository. For each of them, - I only have one branch (Master) - I checked that the remote branch was set correctly (Push and fetch have the same value). I eventually reset the branches - In Synchronization, only "Fetch" is not greyed out. Clicking on it doesn't synchronize. Under "Incoming Commit" is written "The current branch does not track a remote branch". - When working with Git GUI, it works fine, I can easily fetch and push.
我刚刚将 Visual Studio 2015 配置为连接到 GitHub。不幸的是,它无法跟踪远程分支。我在同一个解决方案中有 2 个项目,每个项目都有自己的存储库。对于它们中的每一个, - 我只有一个分支(主) - 我检查了远程分支是否设置正确(推送和获取具有相同的值)。我最终重置了分支 - 在同步中,只有“获取”没有变灰。单击它不会同步。在“传入提交”下写着“当前分支不跟踪远程分支”。- 使用 Git GUI 时,它工作正常,我可以轻松获取和推送。
Please ask if you need more information.
请询问您是否需要更多信息。
Thanks
谢谢
Niko
尼可
回答by Reg Edit
The UI doesn't make it very clear that you have to use Publish without adding a remote repo.
UI 并没有明确说明您必须在不添加远程存储库的情况下使用发布。
If you add a remote first, Publish never becomes available and you get stuck in the "does not track a remote branch" state. I've just had the same trouble in VS2017.
如果您先添加远程,则发布永远不会可用,并且您会陷入“不跟踪远程分支”状态。我刚刚在 VS2017 中遇到了同样的问题。
Wrong way:
错误的方式:
You might think that before you can sync to a remote, you have to tell Visual Studio about the remote. Don't do that.
您可能认为在同步到远程之前,您必须将远程告知 Visual Studio。不要那样做。
Right way:正确的方法:
Instead, hit Sync:
相反,点击同步:
Visual Studio detects that there is no remote configured for the repo, and takes you to the Push dialog:
Visual Studio 检测到没有为 repo 配置远程,并将您带到 Push 对话框:
Press the relevant Publish button, and an input box appears. This is the right place to configure Visual Studio with the URL of the remote repo.
按相关的发布按钮,会出现一个输入框。这是使用远程存储库的 URL 配置 Visual Studio 的正确位置。
When the remote is added this way, Visual Studio recognizes the status of the remote repo so that it no longer thinks it's untracked. From now on, it enables all the sync/push functionality as expected.
当以这种方式添加远程时,Visual Studio 会识别远程存储库的状态,因此它不再认为它未被跟踪。从现在开始,它会按预期启用所有同步/推送功能。