6

I am a new user of Git for Windows. I have installed from Google Code (1.8.1.2, and 1.7 as a trial).

I can issue some git commands, and they are fine and work perfectly. However, the 'git diff' and 'git log' commands do not work. These commands both come back with

'': : command not found

I have tried uninstalling and re-installing. I also have GitHub for Windows on my machine. The machine is Windows 7, very new build.

Could anyone help or give me diagnostic pointers as to why these two commands fail?

Steve Hibbert
  • 2,045
  • 4
  • 30
  • 49

3 Answers3

3

It sounds like your .gitconfig file might not be setup correctly, or the environmental PATH is missing.

For folks that are new to git I almost always recommend that they first start with either

Git Hub for Windows (easiest for new folks)

or

Git Extensions (not sure if this is what you installed)

Chadit
  • 965
  • 2
  • 12
  • 27
  • 1
    .gitconfig is... [user] name = Steve Hibbert email = stevehibbert@email.com [core] editor = subl pager = '' [gui] recentrepo = C:/Home/Rialto – Steve Hibbert Feb 25 '13 at 14:29
  • Path too big to paste, but other git commands work, so I know that git.exe is at least being found, so I assume the git executable directory is in the PATH system environment var. – Steve Hibbert Feb 25 '13 at 14:33
  • It was the .gitconfig - just a blank pager. Thanks for your efforts, much appreciated, cheers. – Steve Hibbert Feb 27 '13 at 12:55
2

Path too big to paste

Make sure your PATH is not too big or it might end up truncated, with strange side-effects (like, potentially, your error messages)

Try and launch git-cmd.bat, or the git-bash shortcut, both included in the msysgit distribution.
They will complement the PATH and set HOME (which is very important, since Windows doesn't set HOME by default)

In those sessions (git-cmd or bash), git diff should work.

The actual solution was like the one in "msysGit: Why does git log output blank lines?": set the pager

[core] 
   pager = less -R
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes, a huge PATH variable would be a problem. I have tested the PATH, by putting a simple batch file in the last named directory (happens to be a JRE7 directory) and calling it from outside that directory - and it's good, so it's not the PATH variable truncating, but good idea. – Steve Hibbert Feb 25 '13 at 15:58
  • ...and yep, I am using Git Bash, I should have included that in original notes. – Steve Hibbert Feb 25 '13 at 15:59
  • @SteveHibbert since you have several Git installed, is there any chance that msysgit tries commands with the wrong git (the one from TortoiseGit or "GitHub for Windows")? Could you try and set a *minimal* path (like `C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\prog\git\PortableGit-1.8.0-preview20121022\bin`) in a `git-cmd.bat` session, and see if that works better? – VonC Feb 25 '13 at 18:14
  • Edited the git-cmd.bat file to a the above minimal path, plus the local location of the git files - same error. I am not sure it's the PATH variable, because some git commands work, and some (log and diff that I have found) do not. Thanks for the test suggestion though. – Steve Hibbert Feb 26 '13 at 14:33
  • @SteveHibbert is there any git alias (see http://stackoverflow.com/a/7066424/6309) which could explain that `diff` and `log` doesn't behave properly? – VonC Feb 26 '13 at 15:20
  • Nope, the .gitconfig is minimalist. It is included in a comment in the section below, the reply from Chadit. – Steve Hibbert Feb 27 '13 at 09:29
  • @SteveHibbert don't forget you have 3 config files. check what `git config -l` returns. – VonC Feb 27 '13 at 10:28
  • Just thought, looking at my gitconfig file, the pager is blank. If the log and diff options use a pager it could be that. What should the pager be on Windows? More? Less? – Steve Hibbert Feb 27 '13 at 12:39
  • Speculatively have set pager to less. This works! The .gitconfig file looks like this... [user] name = Steve Hibbert email = stevehibbert@home.com [core] editor = subl pager = less [gui] recentrepo = C:/Home/Rialto – Steve Hibbert Feb 27 '13 at 12:42
  • @SteveHibbert I would say `less -R`, as in http://stackoverflow.com/a/2899403/6309 – VonC Feb 27 '13 at 12:47
  • Indeed. Thanks for trying to help, it is very much appreciated. I need git for work so without some key commands, life was a bit tricky. – Steve Hibbert Feb 27 '13 at 12:54
  • @SteveHibbert Excellent. I have included that in my answer for more visibility. – VonC Feb 27 '13 at 14:12
2

In .gitconfig, the pager value was an empty string. Any git command that pipes to a pager (ie git-diff or git-log) will fail with a command-not-found because DOS is being asked to run an empty string as a command. No idea how it happened.

Steve Hibbert
  • 2,045
  • 4
  • 30
  • 49