Search code examples
gitcmdalias

`git config --global alias.past = log --pretty=format:"%h|%ad|%s" --date=local` doesn't work


I want to create this alias so that git past is equivalent to git log --pretty=format:"%h|%ad|%s" --date=local. However, when I run the command git config --global alias.past = log --pretty=format:"%h|%ad|%s" --date=local in cmd, it shows this, and then the git past command doesn't work.

What is going wrong? The git config manual suggests this format of creating aliases.
How do I get the desired alias?


Solution

  • There are two mistakes here. First, you need to drop the = character. Second, since the command you want to alias to contains whitespaces, you need to surround it with quotes:

    git config --global alias.past "log --pretty=format:'%h|%ad|%s' --date=local"