2

I have a very, very old file in my Git repo that's had numerous commits to it. By chance, I wanted to compare it to a previous revision but I found that git diff 5.0 Data/schema.sql simply returned no output.

I knew this was wrong, so I ran git log Data/schema.sql. Again: no output!

I thought this could be a gitignore problem, so I completely removed my .gitignore file - no change. I even tried git config --global --get-all core.excludesfile and git config --system --get-all core.excludesfile - both returned no output.

I tried manually adding it with git add. There was no error message, but the file is not mentioned at all in git status - git is acting as if I told it to ignore the file, and on top of that, seems to have made its history inaccessible.

What on earth could be going on? This makes me nervous - this one file's history is not a big deal on its own, but I'm worried that something could be wrong/corupt with my repo as a whole.

What could cause this behavior and how can I fix it? I'm running the latest git (1.8.3.1) on Mac OS X (installed via Homebrew). Other files in the Data directory work as expected, and no other files in the repo exhibit this behavior.

Bill
  • 44,502
  • 24
  • 122
  • 213
  • Poking in the dark here, but is it possible the file ain't readable by the git user? (a chmod issue basically) – Simon Boudrias Jun 28 '13 at 02:59
  • No, unfortunately they have the same owner and mode as other files that work fine. – Bill Jun 28 '13 at 03:09
  • did you try actually changing the file and then running `git status`? – Chronial Jun 28 '13 at 04:02
  • Another shot in the dark: is it possible that file has been renamed? (as in http://stackoverflow.com/a/7759392/6309): `git diff -C 5.0 Data/schema.sql` – VonC Jun 28 '13 at 07:10
  • The file is located in a submodule and your are in the directory of the top module ? – Rasmus Østergaard Kjær Voss Jun 28 '13 at 08:00
  • 1
    Ok. @Chronial's suggestion helped (thanks!). I made a change to the file and ran "git status". I saw that there was a change listed for "data/schema.sql" (lowercase "d"). And "git diff 5.0 data/schema.sql" even works. But the directory has a capital D in my local filesystem. So the problem appears to be this: git thinks that the directory is lowercase and my filesystem thinks it starts with a capital. This is a much more benign problem - still, how do I resolve that? – Bill Jun 28 '13 at 11:35
  • Although I never set this specifically, the Git config variable `ignorecase` is set to true. The default is false. Maybe this is causing the problem? – Bill Jun 28 '13 at 11:47
  • 1
    yes, it is :). Set it to false, then `git status` should say that `data` has been renamed to `Data`. And maybe some others. You can either fix that manually or run `git reset --hard` (but only if you have no uncommited changes!) – Chronial Jun 28 '13 at 13:45
  • Thanks! If you want to make your comment an answer, I'll gladly accept it. – Bill Jun 28 '13 at 14:30

1 Answers1

0

From your comments it looks like this might be a problem with upper/lowercase. Set ignorecase to false and either fix the name manually or reset the repo with git reset --hard (only if you have no uncommited changes).

Chronial
  • 66,706
  • 14
  • 93
  • 99