0

I have been working on my repository for a while but recently received a strange status on one of my files which I will name file.py (I will also name the current branch as my_branch). I am not sure what put GIT in this state, but I can seem to fix it (without falling back to cloning the entire project). GIT now seems completely confused with my change and refuses to revert to old changes.

$ rm file.py
$ git reset --hard
HEAD is now at 42d1b0b Documentation for various modules.
$ ls | grep file.py
file.py
$ git status
On branch my_branch
Your branch is up-to-date with 'origin/my_branch'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   File.py

no changes added to commit (use "git add" and/or "git commit -a")

A little note here, the File.py listed as part of the git status really is capitalized for some reason. The file file.py was pulled down as lowercase. At this point, I am just frustrated and want to get back to work, so I tried to clean everything.

$ git clean -dxf
// Various files cleaned
$ rm file.py
$ git pull
Already up-to-date.
$ git reset --hard
HEAD is now at 42d1b0b Documentation for various modules.
$ ls | grep file.py
file.py
$ git status
On branch my_branch
Your branch is up-to-date with 'origin/my_branch'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   File.py

no changes added to commit (use "git add" and/or "git commit -a")

It is there yet again! Running git diff file.py yields differences too. But the differences are the same as my last commit. Attempting to add the file does not help either as it silently ignores my request.

Any suggestions?

jakebird451
  • 2,288
  • 4
  • 30
  • 45
  • did you try a git checkout -- File.py? – Matt Pileggi Feb 27 '14 at 16:49
  • @MattPileggi Yea, and it doesn't do anything unfortunately. – jakebird451 Feb 27 '14 at 16:53
  • 1
    That is strange. What about making a back up of the file.py, doing a git rm file.py and adding it back in? – Matt Pileggi Feb 27 '14 at 16:55
  • @MattPileggi I performed a `git rm file.py` and interestingly enough it came up with removing both `file.py` and `File.py`. I committed it and re-added the file again in another commit and that seemed to have fixed the problem. Thanks! – jakebird451 Feb 27 '14 at 17:10
  • 1
    nice, glad it worked. Sounds like a case problem. You might be able to avoid it in the future by forcing git to ignore case http://stackoverflow.com/questions/52950/how-to-make-git-ignore-changes-in-case Haven't run into that myself so can't say though – Matt Pileggi Feb 27 '14 at 17:12

1 Answers1

0

Backup the file and remove it with git rm file.py.

Then add the ignore option to your git repo:

git config core.ignorecase true
Atropo
  • 12,231
  • 6
  • 49
  • 62