cmdgitlabaliasgit-bashgit-config

Command: git hist ERROR. fatal: option '--graph' must come before non-option arguments


I am trying to run git hist cmd on GitBash, Windows but I am getting the following error

fatal: option '--graph' must come before non-option arguments

On window PowerShell, I entered:

git config --global alias.hist log --pretty=format: '%h %ad | %s%d [%an]' --graph --date= short"

But still getting the same error.
Please can I know why and how can avoid this error?


Solution

  • Simply move the --graph / --date options first.

    I just tested, from a regular CMD (no PowerShell needed):

    git config --global alias.hist "log --graph --date=short --pretty=format:'%h %ad | %s%d [%an]'"
    

    Then git hist works just fine.

    Note the lack of space between format: and '%h...'