git - 忽略 bash 反引号执行而不转义 git commit 中的 ` 字符

标签 git bash

<分区>

我经常在提交中使用反引号字符。我也经常使用 git commit -m

提交

当我运行这样的命令时

git commit -m "add `foo`"

Bash 尝试执行 foo

我可以使用反斜杠 \ 来转义反引号,但我希望有一个更好的解决方案来避免一直转义反引号。

最佳答案

使用单引号代替双引号。

git commit -m 'add `foo`'

变量、反引号和 $(...) 用双引号展开,但不是单引号。

参见 Difference between single and double quotes in Bash

关于git - 忽略 bash 反引号执行而不转义 git commit 中的 ` 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19913503/

相关文章:

node.js - 如果在 Git bash (mintty) 中使用 npm 脚本,则没有控制台颜色

git - 使用 git-subtree 添加远程仓库的子目录

string - shell bash,你能检查一个函数是否存在吗

git - 为什么 PS1 没有更新 git 分支名称?

c# - 当解决方案包含 Office 应用程序时,从 Github 部署 MVC 站点的 Azure 部署失败

git - 如何将 Bower 与私有(private) Bitbucket 存储库一起使用?

git - 删除提交git

linux - 使用 grep 提取值

linux - 使用 'sh' 运行脚本时无法使用内置 bash 命令

linux - 在 bash 别名中转义字符