无法解析的Git错误:以下未跟踪的工作树文件将被checkout覆盖 [英] Unresolvable Git error: The following untracked working tree files would be overwritten by checkout

查看:6551
本文介绍了无法解析的Git错误:以下未跟踪的工作树文件将被checkout覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2010中单独使用Git进行本地软件项目。最近,我创建了一个新分支来对其中一个对话窗口进行较大的重构。我做了以下修改:
$ b


  • 将Form1重命名为Form1a(包括所有依赖文件)

  • 添加新Form1



我在分支中检查了这种改变,比如说form-refactoring。有趣的是,Git没有注意到我将Form1.cs重命名为Form1a.cs,并创建了一个全新的,完全不同的Form1.cs,但它注意到一个新的Form1a.cs文件,并发现了很多不同之处以前和新的Form1.cs文件。这当然会导致完全垃圾的差异,但我不关心在这种情况下,只要所有文件在最后处理正确。



然后我切换回来掌握一些其他的小变化。没有冲突。到目前为止,一切正常。



今天,我想切换回我的分支表单 - 重构以继续工作。但我得到的是以下消息:

  git.exe结帐表单 - 重构

中止
错误:以下未跟踪的工作树文件将被checkout覆盖:
Form1.Designer.cs
请在移动或删除它们,然后才能切换分支。

这应该是什么?提到的文件不是没有跟踪的。无论是在主分支还是在表单重构分支中。它是两个分支的一部分,但一个不是另一个的后代。如果我删除它会发生什么,它会消失吗?如果我现在删除了一些东西,我不相信Git会恢复正确的文件。除了我提到的Git操作之外,我没有玩过任何文件,为什么我应该使用任何文件来继续使用Git操作? Git破坏了它,现在Git应该处理它!



现在,我无法继续工作,因为我无法切换分支。有没有一个简单的解决方案呢?



Git版本是1.7.6,TortoiseGit是1.7.3。

解决方案

core.ignorecase配置选项未设置,并且Visual Studio已将.Designer.cs文件重命名,以防从大写切换到更低的D(反之亦然)。这是最终的问题。在将该选项设置为true之后,我花了一些文件历史记录分解(删除并重新添加文件)来解决此错误。实际上,这个选项是在一台计算机上设置的,但是当克隆存储库时,设置会以某种方式丢失。然后命运只是等待VS重命名该文件来捕捉我。



因此在Windows上,在任何init之后,您总是需要确保这两个设置是正确的/克隆操作:

  git config core.ignorecase true 
git config core.autocrlf false

code>

有些工具(TGit,gitscc等)似乎没有正确执行。这对于在Windows上正常运行是绝对必要的,但Git不关心它们是否设置不正确,而只是让你偶然发现它们不告诉你为什么。它在说这件事上很有帮助。


I am using Git alone for my local software project in Visual Studio 2010. Recently I created a new branch to do a larger refactoring of one of the dialogue windows. I did the following modifications:

  • Rename Form1 to Form1a (including all depending files)
  • Add new Form1

I checked this change into the branch, say form-refactoring. Interestingly, Git didn't notice that I renamed the file Form1.cs into Form1a.cs and created a brand new, totally different Form1.cs, but instead it noticed a new Form1a.cs file and found a whole lot of differences between the previous and new Form1.cs files. This will of course lead to totally garbaged diffs, but I don't care in this case as long as all files are handled correctly in the end.

Then I switched back to master to do some other small changes. Nothing conflicting. Until now, everything worked fine.

Today, I wanted to switch back to my branch form-refactoring to continue that work. But all I get is the following message:

git.exe checkout    form-refactoring

Aborting
error: The following untracked working tree files would be overwritten by checkout:
Form1.Designer.cs
Please move or remove them before you can switch branches.

What is that supposed to be? The mentioned file is not untracked. Neither in the master branch, nor in the form-refactoring branch. It is part of both branches, but one is not a descendent of the other. What would happen if I delete it, is it gone for good then? I don't trust Git to bring back the correct file if I delete something now. I did not play with any file at all outside of my mentioned Git operations, so why should I play around with any file to continue using Git operations now? Git broke it, Git's supposed to handle it now!

Right now, I cannot continue with my work because I cannot switch branches. Is there an easy solution to this?

Git version is 1.7.6, TortoiseGit is 1.7.3.

解决方案

The core.ignorecase config option was not set and Visual Studio had renamed the .Designer.cs file in case, switching from a capital to lower "D" (or vice versa). That was the problem in the end. It took me some file history breakup (deleting and re-adding files) to resolve this error after setting the option to true. Actually the option was set on one computer, but when cloning the repository, the setting got lost somehow. And then destiny was only waiting for VS to rename that file to catch me.

So on Windows, you always need to make sure that these two settings are correct after any init/clone operation:

git config core.ignorecase true
git config core.autocrlf false

Some tools (TGit, gitscc etc.) don't seem to do it right. It's absolutely necessary for normal operation on Windows, but Git doesn't care if they're not set correctly and just lets you stumble over them not telling you why. It's as much lying as it's helpful in this matter.

这篇关于无法解析的Git错误:以下未跟踪的工作树文件将被checkout覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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