Bill
Bill

Reputation: 45418

Why would git log/status return no output?

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?

Upvotes: 6

Views: 4439

Answers (4)

msr
msr

Reputation: 346

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
...

Upvotes: 0

Paiman Roointan
Paiman Roointan

Reputation: 574

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)

Upvotes: 0

Chris
Chris

Reputation: 6193

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.

Upvotes: 0

Nick Volynkin
Nick Volynkin

Reputation: 15099

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.

Upvotes: 5

Related Questions