git 切换分支不会刷新 Visual Studio 中的解决方案资源管理器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28632922/
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
Switching branches does not refresh Solution Explorer in Visual Studio
提问by Bryan Dellinger
I am probably missing something basic here, but I'm playing around with the Git version of TFS.
我可能在这里遗漏了一些基本的东西,但我正在使用 TFS 的 Git 版本。
I am using Visual Studio 2015 preview (maybe that is my problem), so from a solution I created a master and I made a branch from this master; I'll call it version2.
我正在使用 Visual Studio 2015 预览版(也许这就是我的问题),所以从一个解决方案中我创建了一个 master 并且我从这个 master 创建了一个分支;我称之为版本2。
I made changes to version 2, but I did not commit merge sync or anything. So after messing around with version 2 I went back into Team Explorer, went to the branches tab, and double clicked main (I also tried right click switch).
我对版本 2 进行了更改,但我没有提交合并同步或任何内容。因此,在弄乱版本 2 之后,我又回到了团队资源管理器,转到了分支选项卡,然后双击了 main(我也尝试过右键单击开关)。
I was hoping my Solution Explorer would not show the changes I made to version 2, because I had now switched to main. But that is not the case, and I am still seeing all the changes I made in version 2 in Solution Explorer. So how do I get Solution Explorer to reflect the branch I am currently working on?
我希望我的解决方案资源管理器不会显示我对版本 2 所做的更改,因为我现在已经切换到主版本。但事实并非如此,我仍然在解决方案资源管理器中看到我在版本 2 中所做的所有更改。那么如何让解决方案资源管理器反映我目前正在处理的分支?
采纳答案by Daniel Mann
Git's model is fundamentally different than TFVC. You need to commit the file to your branch (you don't necessarily need to push the change or the branch to the remote server). Once you commit the change, switching branches will behave in the fashion you're expecting.
Git 的模型与 TFVC 有着根本的不同。您需要将文件提交到您的分支(您不一定需要将更改或分支推送到远程服务器)。一旦您提交更改,切换分支将按照您期望的方式运行。
Git is based on the model of committing changes to local branches frequently. Even if the code doesn't yet compile, it's fine to commit it to a local branch... you can always rebase or cherry-pick later on.
Git 基于频繁提交更改到本地分支的模型。即使代码尚未编译,也可以将其提交到本地分支……以后您可以随时进行变基或挑选。
回答by MrHinsh - Martin Hinshelwood
By default in Git if you have pending changes that you have not committed and you switch branch the changes are moved to the new branch. Git is assuming that this is what you want.
默认情况下,在 Git 中,如果您有未提交的未决更改,并且您切换分支,则更改将移动到新分支。Git 假设这就是你想要的。
If you want to leave the changes on v2 you need to commit the changes with that branch checkout. You can then switch to the v1 branch and see the solution change.
如果您想将更改保留在 v2 上,您需要使用该分支检出提交更改。然后您可以切换到 v1 分支并查看解决方案的变化。