enableGitInfo: "Got error reading Git log: exit status 128"

“Got error reading Git log: exit status 128”

which git: /usr/bin/git

cat .gitignore


Command I ran

hugo serve --enableGitInfo

How can I debug this to get more than just exit status 128?

You currently can not, I’m afraid. I have added this issue to track it (see below).

  • My first guess would be a path issue, but that does not seem to be it.
  • My second guess would be that you use a “too old” Git version, i.e. we use some options not available in your’s, see

Thank you

git version 2.11.0 (Apple Git-81)

excerpt of my $PATH


I tried making a new hugo site with no content and initing a git repo, same error.

Hugo Static Site Generator v0.21

Is my git updated enough? Are there any other things I could try to debug?

(I’m hoping to use this for the automatic lastmod functionality for my sitemap)

This is my git:

▶ git version
git version 2.12.2

So your Git should be fine. I’m sorry, but I cannot help you remotely with this one; I will put it on my list to fix that error message, but that is of no help for you now. But I have used it myself and know others have without any issues, so …

I install git from brew so you might try that, to get a more recent one than the default one Apple supplies. Mine is 2.13.0. @arikroc

Thanks @RickCogley

Tried that and now have

git version 2.13.0

still same error, “Got error reading Git log: exit status 128”

@arikroc hmm. Are you running the hugo server command from where it can see the git log, i.e. from your repo? I have my hugo server commands set up as zsh functions, which cds to the appropriate repo root before I run them.

Yes. I’m running hugo server and git commit/log/etc from the same directory (that contains my .git folder)

Any other ideas?

@arikroc what happens when you run git log with the same args that Bep cites in the code above?


git -C %s log --name-only --no-merges
fatal: Cannot change to ‘%s’: No such file or directory

Then replacing %s with the current directory:

git -C . log --name-only --no-merges --format=format:%%x1e%%H%%x1f%%h%%x1f%%s%%x1f%%aN%%x1f%%aE%%x1f%%ai



The %s is a variable being used by the go code.

@RickCogley Yep sorry I realized that after posting and edited my post above

@RickCogley And now I realize %% is escaping the string, so the proper result is:

git -C . log --name-only --no-merges --format=format:%x1e%H%x1f%h%x1f%s%x1f%aN%x1f%aE%x1f%ai

c3dd02d2dde75d3f88681487826bed93461fa123c3dd02dinitial[name][email]2017-05-28 15:03:19 -0700

380c709108742508c7a3b1fafbacfad8a081d7e7380c709test[name][email]2017-05-28 11:48:14 -0700

@bep Anything else you’d suggest trying?

Sorry, not at this point.

1 Like

@RickCogley any other ideas?

Hmm, not really @arikroc. I am using a zsh function to run my various hugo servers, so the ports don’t conflict:

 function hugoserver-rc5 {
     cd /path/to/rc5
     hugo server --buildDrafts --watch --verbose --source="/path/to/rc5" --config="/path/to/rc5/config.toml" --port=1314 

… and I tried it with and without --enableGitInfo. Actually, I just have that in my config.toml so it should be redundant from the cli, but, I tried it either way, with no error.

~../rc5 ❯ git version                                                                                            
git version 2.13.0
~../rc5 ❯ which git                                                                                              
~../rc5 ❯ hugo env                                                                                            
Hugo Static Site Generator v0.22-DEV-421A4694 darwin/amd64 BuildDate: 2017-05-25T11:58:11+09:00

Darn. Okay, thanks for the info :slight_smile: I appreciate that you included it

1 Like

@bep @RickCogley I’ve got it! Just did this ~1.5 mins ago.

Realized my hugo project is in a sub directory and one of the upper level folders had a space in the name.

So I renamed that folder so it had no space in the name.

And presto, it works, perfectly.

So for anyone else that experiences this issue:

Make sure there is no whitespace in the names of any of the folders in the entire folder tree that contains your hugo project directory

Glad to hear it. Maybe hugo can be made to detect or deal with a space in the path. Or maybe you just need to specify the paths exactly in the hugo server command. Since they are quoted, I wonder if specifying them exactly in the args, or, perhaps escaping the space would change it.

As for me, I always avoid spaces in paths where I can, since there’s always something like this that happens, in my experience.

1 Like