VS 中的 TFS/GIT 无法切换到 master,因为有未提交的更改 [英] TFS/GIT in VS Cannot switch to master because there are uncommitted changes

查看:27
本文介绍了VS 中的 TFS/GIT 无法切换到 master,因为有未提交的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在visualstudio.com 上为VS 2013 解决方案设置了一个GIT 存储库.当我习惯使用 TFS(在 GIT 模式下)时,存储库运行良好.

I've setup a GIT repository for a VS 2013 solution on visualstudio.com. The repository worked great while I was becoming accustomed to using TFS (in GIT mode).

然后我决定熟悉一下 Branches,所以我从 master 上创建了一个分支.我在这个分支中做了很多改变.我已经随着时间的推移提交了更改并执行了同步以将我的本地提交推送到 visualstudio.com 存储库.这一切都有效.

Then I decided to familiarize myself with Branches, so I created a branch off of the master. I've made quite a few changes in this branch. I've committed the changes over time and have performed a Sync to push my local commits to the visualstudio.com repository. This all works.

我遇到的问题是我不知何故失去了切换回主分支的能力.我无法将新创建的分支合并到主分支中.每次我尝试做任何涉及主人的事情时,我都会在 VS 中收到以下错误:

The problem I am having is that I somehow lost the ability of switching back to the master branch. I cannot merge my newly created branch into the master. Every time I try to do anything that involves the master I get the following error in VS:

无法切换到 master,因为有未提交的更改.在切换分支之前提交或撤消更改.有关详细信息,请参阅输出窗口.

Cannot switch to master because there are uncommitted changes. Commit or undo your changes before you switch branches. See the Output window for details.

输出窗口从不包含任何详细信息"...

The Output window never contains any 'details'...

此消息指的是什么未提交的更改"?由于我无法进入主分支,我无法提交任何更改(我也不确定我想要?).并且我所在的当前(仅其他)分支已提交并同步.

What "uncommitted changes" does this message refer to? Since I cannot get into the master branch I have no way of committing any of its changes (nor am I sure that I want to?). And the current (only other) branch I am in has been committed and sync'ed.

我真的只是在学习 TFS、GIT 和源代码控制.我如何安全地从这个问题中恢复?

I'm really just learning TFS, GIT and source control. How do I safely recover from this problem?

推荐答案

好吧,我自己也遇到了与 rwkiii 相同的问题 - 这是 Visual Studio 中的一个错误,不容易修复.以下是症状:

Okay, I had the same issue myself as rwkiii - this is a bug in Visual studio and is not an easy one to fix. Here are the symptoms:

Visual Studio 声明您不能合并/切换分支/等.因为您有未提交的更改 - 这很好,除非您的所有更改已经提交.

Visual Studio states that you cannot merge/switch braches/etc. because you have uncommitted changes - which is fine, except all your changes have been committed.

无法切换到 master,因为有未提交的更改.在切换分支之前提交或撤消更改.有关详细信息,请参阅输出窗口.

Cannot switch to master because there are uncommitted changes. Commit or undo your changes before you switch branches. See the Output window for details.

这是一张截图,更清晰.

如果您查看输出窗口,它可能会显示为空,但您必须将显示输出"更改为源代码控制 - Git".这将列出 Visual Studio 认为有更改的文件.

If you look at the output window, it may appear empty but you have to change "Show output from" to "Source Control - Git". This will list the file that Visual Studio thinks has changes.

现在,我尝试过的事情没有修复它(所以你不必):

Now, things that I tried that didn't fix it (so you don't have to):

  • 重新启动 Visual Studio
  • 重启机器
  • 切换项目
  • 使用外部 git 工具(所有这些都说没有变化")
  • git 重置
  • 对文件进行任意更改并提交.提交确定,VS 仍然认为还有更多变化

最后,我不得不从磁盘中删除文件,然后从团队资源管理器窗口撤消"更改:

In the end, I had to go and delete the file from the disk, then "undo" that change from the Team Explorer window:

不是最理想的解决方案,但似乎确实可以解决问题.

Not the most ideal solution, but it does seem to fix it.

这篇关于VS 中的 TFS/GIT 无法切换到 master,因为有未提交的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆