I did
git commit -m "Changed function name `sum` to `sum_list`"
My intention with the backticks was that sum
and sum_list
be typed in a monospace font when someone views the commit message in GitHub or the like. It works like this in other contexts, for example in Markdown.
However this didn't work well. A git log
shows the following commit message:
Changed function name to
When I googled this, I only found this question about backtick commands, but both the asker and the answerer are already familiar with the concept I am trying to understand.
What do backticks do in commit messages? And is there a way to mark parts of the commit message as monospace font?
TLDR: Use single quotes:
$ git commit -m 'Changed function name `sum` to `sum_list`'
Using backticks is a way to tell the shell to execute the content, it's called a command substitution, consider the following:
$ echo "hello `ls` world"
hello Applications
Desktop
Documents
Downloads
Library
Movies
Music
Pictures
Public world
When using single quotes the only special character is another single quote:
$ echo 'hello `ls` world'
hello `ls` world
It's all up for interpretation of the UI on how they will show your git commit message, maybe backticks will render specially in your UI, but consider that the lowest common denominator is git log
.