gitbash

Ignore Bash backtick execution without escaping the ` character in a Git commit


I use the backtick character in my commits very often. I also usually commit using git commit -m.

When I run a command like this,

git commit -m "add `foo`"

Bash tries to execute foo.

I can use a backslash \ to escape the backtick, but I am wishing for a better solution to avoid escaping backtickes all the time.


Solution

  • Use single quotes instead of double quotes.

    git commit -m 'add `foo`'
    

    Variables, backticks, and $(...) are expanded in double quotes, but not single quotes.

    See Difference between single and double quotes in Bash