10

I have a number of git repositories (with commits) and each displays nothing when running git log. If I run the command outside a project directory (without a git repository) I get:

fatal: Not a git repository (or any of the parent directories): .git

I tried re-installing Git (I'm now running 1.7.5.4) and re-cloning my repositories to no avail. Any ideas?

Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232

8 Answers8

16

git log does not show any commit!

I noticed that not only git log command but also man command does not show anything for me. It turned out that I just needed to set the PAGER environment variable to less or more programs to solve both problems.

export PAGER=less
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Farhad Maleki
  • 3,451
  • 1
  • 25
  • 20
7

I've just experienced the same problem, of git log not displaying anything for a particular file. The problem turned out to be Windows was displaying the directory name with an upper-case first letter, but git expected the first letter to be lower-case. So "git log Subdir/file.c" produced no errors and no output. Whereas "git log subdir/file.c" produced the expected revision history.

BrentNZ
  • 116
  • 1
  • 4
  • I am observing now slightly the same: under Windows, `git log` for some particular file gives an empty output, but `git diff` to the same file works fine. Other files in the same directory seem not affected. I tried different command line options to git, but the output is still empty. – dmi Feb 15 '17 at 12:10
  • I got a solution to my issue. The problem appeared when I tried to say `git blame` to my file and it complained. Then I checked with `git branch --all` that my HEAD points to branch `main`, but I am in the branch `master`, and `master` differs from `main`. No much clue what happend, but I deleted branch `main` and moved `master` to `main`. After that manipulation everything works again for me :) – dmi Feb 15 '17 at 13:58
5

May be that the pager is not set up correctly with git.

Diagnostics:

git config core.pager

If it gives empty output or something unexpected, it may be the cause of the problem.

Solution

Try one of the following with xxx = more, less or other pager of choice:

git config core.pager xxx
git config --global core.pager xxx
PGlivi
  • 996
  • 9
  • 12
0

I have the same problem (and "git diff" doesn't work either), I still do not know why but I workaround :

git rev-list --all --reverse

Or better (only 10 last commits with message information) :

git rev-list --all --max-count=10 --reverse --pretty
0

i had the similar issue with a log to a file. 1] get a list of your config files git config --list 2] check this entry core.filemode=false change it to true git config core.filemode true 3] check your files path in gitk 4] i had the wrong path. now it works. git log -- ./Documents/holdMe.txt

Fred Fuchs
  • 31
  • 4
0

For those who still don't come up with solution: Check your firewall, mine (Comodo on windows10) was blocking Git\usr\bin\less.exe.

After removing it from blocked apps it worked fine.

beatrice
  • 3,684
  • 5
  • 22
  • 49
0

The fatal error for running a git command outside a project directory is expected. Not getting any log messages at all for running git log is not.

Try running gitk to see if you can see the log history there.

citizen conn
  • 15,300
  • 3
  • 58
  • 80
0

If you do not have any commits, it would not show anything and error. Also, if you don't have a current commit in a bare repo, you can still show all commits in a repo with `git log --all'.

You can also see what branches you have with

git branch -a

then you can git checkout branchX. You would be able to get output from git log then - provided you have some commits there. If you have bare repos, you can't checkout.

Hope this helps.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • 1
    He says he has many repos, none of them have have any commit? No chance. And what do you mean by `if you don't have a current commit` ? If you are talking about detached head, it still shows a log as commits are still pointing to their parents. – manojlds Jul 12 '11 at 23:33