Git log alias - fatal: ambiguous argument '%ad': unknown revision or path
Here is the source of the error message:
$ git log %ad
fatal: ambiguous argument '%ad': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
You will get the same error message from the following two commands:
$ git log --pretty=format:%h %ad | %s%d [%an] --graph --date=short
$ git log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
The problem is that git log
receives the following two arguments: --pretty=format:%h
(or --pretty=format:\"%h
) and %ad
. The rest, at least when executed directly as a command in bash, is a pipe to the command %s%d
, which usually does not exists. The full error message on my system thus looks like this:
$ git log --pretty=format:%h %ad | %s%d [%an] --graph --date=short
bash: %s%d: command not found
fatal: ambiguous argument '%ad': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
All this demonstrates that the quoting somehow got lost and %ad
is interpreted as a parameter for git log. To prevent that you have to find the correct combination of quoting and escaping so that the format string is quoted correctly at time of execution.
The git config manual about alias and quoting:
Arguments are split by spaces, the usual shell quoting and escaping is supported. quote pair and a backslash can be used to quote them.
From this line I was not able to figure out how quoting and escaping works. I tried some combination of quoting and escaping in the alias but was not able to make any sense out of it.
The following lines you posted in your question works fine on my system:
[alias]
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
You will have to experiment to get the right combination on you system while using PuTTY and all.