Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
728 views
in Technique[技术] by (71.8m points)

windows - Git status shows file twice but different case

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...