5

I have a very old git repository (about six years old) and noticed that I wasn't seeing changes I'd made to a file in my git status output.

I ran the command on the specific file in question:

$ git status Data/schema.sql
$

and got no output! This file has been in the repo since the beginning. Additionally, if I checkout the repo to another directory, the file (strangely enough) appears there.

I saw the same with git diff Data/schema.sql and git log Data/schema.sql.

Normally, when something like this happens, it's a gitignore problem. But even removing my .gitignore file caused no change in this behavior.

What could cause this behavior?

Bill
  • 44,502
  • 24
  • 122
  • 213
  • are you sure Data/schema.sql is added to your stage changes ? (aka git add Data/schema.sql) – Franck Jun 10 '15 at 23:06
  • I tried `git add`. There was no output and it didn't change the output of `git status` or `git diff`. – Bill Jun 10 '15 at 23:06
  • Could it be an old git version installed on your server? or are you storing the code on github/bitbucket or something else ? – Franck Jun 10 '15 at 23:12
  • what happens if you do `git status [remote_name]/master`? – locoboy Jun 10 '15 at 23:31
  • @NickVolynkin I get a number of dangling blobs, but no errors or problems. – Bill Jun 11 '15 at 10:57
  • 1
    Have you marked the file with a `skip-worktree` or `assume-unchanged` bit? – Sascha Wolf Jun 11 '15 at 11:16
  • @Zeeker Not intentionally. Is there a way to check the bits assigned to the file? – Bill Jun 11 '15 at 11:40
  • 2
    `git ls-files -v | grep -i '^S'` should return all files marked in such a way. – Sascha Wolf Jun 11 '15 at 11:48
  • 1
    @Zeeker It's not marked that way, but that did help me - it shows up in the list as "data/schema.sql" (no capital "D"). `git log data/schema.sql` works as expected. Thanks for the tip about `git ls-files`! Now, how do I fix this? `ls-files` shows some entries as `Data/blah.sql` and some as `data/blah.sql` – Bill Jun 11 '15 at 12:16
  • i.e. How do I get the directory name to be capitalized the same way everywhere in git's view? – Bill Jun 11 '15 at 12:16
  • 1
    @NickVolynkin Worked perfectly! Thanks for your help. If you rewrite this as an answer, I'd gladly accept the answer. – Bill Jun 11 '15 at 13:47
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/80305/discussion-between-nick-volynkin-and-bill). – Nick Volynkin Jun 11 '15 at 16:32

4 Answers4

5

This "symptom" has two possible "diagnoses":

A case-insensitive forced rename back in history

Diagnostics:

git ls-files

Search for paths with different capitalizations:

some/path/foo
Some/path/bar

Solution

git mv -f Some/path/* some/path/

It's important to move all files (/*) to the renamed path. Now they will all have a single path.

Possible cause

There may be a situation when some/path has several files with it, tracked with different letter cases in the path. For such files providing an "incorrect" path to git log or git status results in abscense of some commits in the log output.

This bug is reproduceable with git mv -f <path/file> <PATH/file> on Git 1.9.5 and maybe on newer versions (will check later).

git log Some/path/foo

The log will not contain some commits made before the git mv -f some/path/bar Some/path/bar was executed.

Files marked with a skip-worktree or assume-unchanged bit

Thanks to @Zeeker for this assumption.

Diagnostics:

git ls-files -v | grep -E '^(S|[a-z])'

For additional information take a look at the git ls-files documentation.

Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73
Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67
0

TL;DR: check for other running git-clients.

I just had a similar issue: zero output from git.

git status, git log, git fetch: all the same. Nothing. An empty line and back to the command-prompt.

I would only get responses when I was in the parent directory, which was not a repository or in a different repository. Also, I got errors and suggestions for mis-typed commands. So it was not totally dead. Just in hibernation - or something.

The first response that I found was to git branches which properly printed the known branches. So I played with branches and used git checkout master which gave me nothing and all the above commands had not changed. All nothing. When I tried to switch back to develop I got a clue:

fatal: Unable to create 'I:/foo/bar/repo/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

I found a running git-UI-client (GitKraken in my case) and closed it. Fixed. Maybe the problem had something to do with the fact that my repo was on a Windows network share.

Chris
  • 5,788
  • 4
  • 29
  • 40
  • Now this problem has three possible diagnoses :) – Chris Apr 15 '19 at 15:34
  • I didn't have the same but a similar one, git status was working but git log not. Restarting my session fixed it, probably another running git process(es) caused the issue. – Burak Karasoy Jul 25 '19 at 07:55
0

I was doing git log in the deepest folder in windows. wasn't working. so I tried git ls-files. it was also not working

I went up through folders enough times, until git ls-files worked, and then used git log with the relative file path.

Don't have any idea what causes this, but this solved the problem for me. (at least temporarily)

Paiman Roointan
  • 514
  • 5
  • 17
0

I find that if using the MINGW64 Bash shell that ships with some versions of git, their attempt to manage case sensitivity can cause this failure. To fix the problem, "cd" with the correct capitalization. In the example below, the correct directory name is "CalMAN App". However, if you cd to "calman app" that works. Unfortunately, it confuses git.

micha@mrosen-win1 MINGW64 ~/dev/CalMAN/src/CalMAN/calman 5 (master)
$ cd "calman app"

micha@mrosen-win1 MINGW64 ~/dev/CalMAN/src/CalMAN/calman 5/calman app (master)
$ git log .

micha@mrosen-win1 MINGW64 ~/dev/CalMAN/src/CalMAN/calman 5/calman app (master)
$ cd ..

micha@mrosen-win1 MINGW64 ~/dev/CalMAN/src/CalMAN/calman 5 (master)
$ cd "CalMAN App"/

micha@mrosen-win1 MINGW64 ~/dev/CalMAN/src/CalMAN/calman 5/CalMAN App (master)
$ git log .
commit 41d026ddf3282227932136245092aaabace4aded
...

msr
  • 336
  • 3
  • 7