4

I'm using git on Windows. I once added a file, then changed a letter in upper case, added it again with the new name. From then, I always had the two files (once with upper case, once not).

 myFile.ext
 myfile.ext

Git always interpreted it as two distinct files (as it was configures case sensitive) but it was actually the same file, so it was tracking this file two times, once under each name.

I have now deleted the upper case file from the repo with

git rm --cached myFile.ext

So I have now only one track of my file, and that's all good.

 myfile.ext

The problem is that if I want to make a checkout on an older commit, git says :

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

However, I can't do anything with this file, because it's not in the working tree nor in the index. I tried to move the file, remove the myfile.ext file and add it again, stash, but nothing worked. The myFile.ext doesn't show in the git status and is not in the gitignore.

How can I solve this?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Oswin
  • 539
  • 1
  • 6
  • 20
  • Try to use git clean, look for details here: http://stackoverflow.com/questions/4858047/git-error-the-following-untracked-working-tree-files-would-be-overwritten-by-ch – demonplus Apr 09 '15 at 13:01
  • 1
    What is your `core.ignorecase` configuration setting? – Edward Thomson Apr 09 '15 at 15:10
  • Try "git clean -fd" to force remove untracked files. – Mayur Nagekar Apr 09 '15 at 17:35
  • core.ignorecase = false, but only recently, after I added the files. Clean with different options didn't solve the problem. Actually I can checkout forcing with -f, but it's no long term solution, the error persists. – Oswin Apr 10 '15 at 14:28

1 Answers1

1

Perhaps the best is to remove the myFile.ext from your history with command like:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch myFile.ext' HEAD
Yves Blusseau
  • 4,244
  • 4
  • 16
  • 7