Git状态显示文件两次,但不同的情况 [英] Git status shows file twice but different case
问题描述
我尝试搜索我的问题,并且找到最接近我的信息。
git Status显示两次相同的文件 - 但使用不同的路径斜杠样式
但我似乎没有这个问题。
我在做一个提交,并注意到相同的问题文件列出了两次,但案件不同。例如, Directory / resource.h
和 Directory / Resource.h
。现在在 resource.h
目录中只有一个文件。如果我通过Git Extensions查看文件,它们看起来完全一样。似乎没有另一个隐藏的文件,只有一个文件。所以我试图通过删除 resource.h
文件,提交,然后添加文件来解决这个问题。并再次重新提交。只有一个文件显示为已添加。我以为我解决了这个问题,但现在如果我尝试检出一个不同的分支,我会得到以下错误。
error:The以下未跟踪的工作树文件将被checkout覆盖:
Directory / Resource.h
请在移动或删除它们,然后才能切换分支。
中止
完成
我真的不知道该怎么办从这里开始,我只用了几个月的Git,而且我没有必要做比合并分支和推拉更复杂的任何事情。
如果您有一个包含 ignorecase = false
的repo,并且不使用git重命名文件,则可能发生在Windows中。要解决这个问题,应该可以工作
git mv -f Resource.h resource.h
git commit -m'fix case'
并且这应该防止它再次发生。
git config core.ignorecase true
I tried to do a search for my issue and the closest thing that I could is this.
git Status Shows Same File Twice - But with different path slash styles
But it doesn't seem to be the same issue I have.
I was doing a commit and noticed that the same file was listed twice but with different case. For instance, Directory/resource.h
and Directory/Resource.h
. Now there is only one file in the directory resource.h
. If I look at the file through Git Extensions they look exactly the same. There doesn't seem to be another hidden file, there is only one file.
So I tried to fix this by removing the resource.h
file, committing, and then adding the file back and recommit again. Only one file showed up as added. I thought I fixed the issue, but now if I try to checkout a different branch I get the following error.
error: The following untracked working tree files would be overwritten by checkout:
Directory/Resource.h
Please move or remove them before you can switch branches.
Aborting
Done
I don't really have any idea what to do from here, I've only been using Git for a few months and I haven't had to do anything more complicated than merging branches and pushing and pulling.
This can happen in Windows if you have a repo with ignorecase = false
and rename a file without using git. To fix, this should work
git mv -f Resource.h resource.h
git commit -m 'fix case'
and this should prevent it from happening again.
git config core.ignorecase true
这篇关于Git状态显示文件两次,但不同的情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!