Search code examples
gitcommentsaliases

Is there a right way of adding comments to git aliases?


Many git aliases have very short abbreviations/acronyms/TLAs and long, almost impenetrable, command lines.

Is there a 'correct' way of adding a trailing comment to an alias so that I can remember what it was for, or where I got it from?

Does it depend on whether it was created via the git config --global alias.<shrt> 'cmd' command or by directly editing my .gitconfig file, and also if it is a shell ! command etc.

It would be great if there was a 'one size fits all' method.


Solution

  • The config file has a comment syntax, use that.

    The first two sentences of the Syntax section in git help config:

       The syntax is fairly flexible and permissive; whitespaces are mostly ignored.
       The # and ; characters begin comments to the end of line, blank lines are ignored.