git - 无法 pull ,因为使用 VS2015/Git 有未提交的更改

标签 git visual-studio visual-studio-2015 dev-null

想象一下下面的场景:

Manager has created a team project and decided to use (latest) git as VCS for the project. Developer team will be working using (latest) VS2015 (Enterprise) IDE. Manager has created a new (origin) branch called "master" and then committed & pushed 2 files to that branch.

项目文件层次结构:

  Project (Root) Folder
    | notes.txt
    \ readme.md

由“Jym”和“Bennie”组成的开发团队已经 pull 了 origin/master 分支(他们都在 local/master 分支上工作)。 Jym 已将第一个更改提交并推送到“notes.txt”文件(直接到 master 分支)。 Bennie 创建了一个名为“todos.txt”的新文件,并对“notes.txt”文件进行了一些更改。 现在,当 Bennie 尝试同步/pull 更改(Jym 之前所做的更改)时,同步窗口中会显示以下消息:

Cannot pull because there are uncommitted changes. Commit or undo your changes before pulling again. See the Output window for details.

让团队的事情变得更糟的是,Bennie 还经历了确切的 same issue that was opened in late December last year .这意味着 Bennie 实际上无法运行任何 git 命令(但是,除了“撤消”之外的所有功能似乎都可以与 Visual Studio Git/TFS 提供程序一起正常工作 - 他发现这真的很奇怪)。
也正因为如此,这个问题不是(可能)重复 another question .

如何解决 Bennie 遇到的问题(根据上述场景)(当然只使用 Visual Studio)?

如果我可以提供更多详细信息,请发表评论。

编辑 1(从 suggested answer 输出 solving "null" device ):
第一步的结果:这不是答案中的错字吗,“nul”不应该是“nil”吗?
See screenshot

第二步的结果(设备管理器): 选中“查看”->“显示 stash 的设备”选项后,任何设备名称中都没有带有小“警告”图标(未知/无法识别的设备)或“空”的设备。
此外,显然“非即插即用驱动程序”类型甚至没有被列出(当然是在选择“查看”->“按类型分类的设备”时)。

第三步的结果:%SystemRoot%\system32\drivers\null.sys 文件已存在并已从磁盘中删除(复制并粘贴到 null.sys 中)。来自 Windows 10 的 sys 文件)。
更多详细信息:一旦右键单击这些 sys 文件中的任何一个,上下文菜单中就没有“安装”或“卸载”选项,默认操作似乎是“打开方式...”(粗体)。

第四步的结果:尝试 merge null.reg失败的。重新分配 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root 注册表项的所有者,同时设置适当的权限。
null.reg更新注册表项权限后,文件已成功 merge 到注册表中。
重新启动计算机。
等待最终答案……错误仍在显示!
See screenshot

EDIT 2(测试 PATH 环境变量):
See screenshot 同样的错误仍然发生(即使在以管理员身份打开 git-cmd.exe 或 git-bash.exe 之后)。

EDIT 3(电源选项,不使用“允许计算机进入离开模式”设置):
Reference thread .
See screenshot

编辑 4:
Bennie 将他的机器从 Windows 8.1 升级到 10 后,问题就解决了。我们现在可以简单地得出操作系统已损坏的结论。

最佳答案

每当 GUI(这里是带有 Git 集成的 VS)走出标称路径(这里不是立即可能的 git 推送)时,恢复到 git 命令行界面。

在您的情况下,Bernie 需要一个 git pull --rebase

打开一个 git bash,然后做(像伯尼一样)

cd /path/to/repo
git status # make sure everything is committed
git pull --rebase
git status # you see notes.txt as being in conflict
# edit notes.txt and resolve the conflict by removing merge markers
git add .
git rebase --continue

git push

请注意,git pull --rebase 可能 很快就会出现在 Got for Visual Studio 中(遵循 @gitforvs ):

g4vs

虽然还没有官方消息。


关于“Couldn't open/dev/null (or dup failed)”,查看“Getting errors when using GitHub for Windows”是否有帮助(关于 null device 的问题)。

如果错误仍然存​​在,如 git-for-windows/git issue 583 ,重新安装 Windows 仍然是摆脱这种困境的最可靠方法。

OP OmegaExtern 所述在Edit 4中,从win8升级到win10即可恢复设备并解决问题。

关于git - 无法 pull ,因为使用 VS2015/Git 有未提交的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35111573/

相关文章:

git - 致命的 : Authentication failed in git in cmd

git - merge 后压缩 Git 提交

git - 我的 Git 配置中的设置来自哪里?

visual-studio - typescript 文件的 Visual Studio 个人设置

jquery - Cordova for Visual Studio 2015 预览版 : not able to request content from a remote host

git - Visual Studio 2015 将仅使用 git 进行源代码管理

eclipse - 如何使用 Eclipse 创建默认分支?

c# - 什么在调用?

c# - 在 C# 中,有没有办法在调试器中抑制异常进入调试器?

python - Visual Studio,Python 不自动缩进