Search code examples
gitdockergit-logstrftime

Git log: "unknown date format"


This is the command I'm running, and its error:

# git log --pretty=format:"%ad" --date=format-local:"%y-%m-%d %k:%M"
fatal: unknown date format format-local:%y-%m-%d %k:%M

The same command works fine on other machines. I'm running into this error inside an ubuntu docker container. Other formats throw the same error:

# git log --pretty=format:"%ad" --date=format-local:"%M"
fatal: unknown date format format-local:%M
# git log --pretty=format:"%ad" --date=format-local:"%m"
fatal: unknown date format format-local:%m
# git log --pretty=format:"%ad" --date=format:"%m"
fatal: unknown date format format:%m

It seems like I'm missing a date-formatting dependency that wasn't a part of the docker image.

EDIT: I'm using git version 1.9.1.


Solution

  • Use git --version to view the version of Git you are running.

    --date=format:strfime-format is new in Git version 2.6.0. If you are running in an environment that has an older version of Git, it's simply not available.

    The --date=format-local: feature is new in Git version 2.7.0 (so between those two you can use format: but not format-local:, even though you can use --date=local).