Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would git log/status return no output?

Tags:

git

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?

like image 559
Bill Avatar asked Jun 10 '15 23:06

Bill


1 Answers

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.

like image 84
Nick Volynkin Avatar answered Nov 12 '22 10:11

Nick Volynkin