Git 别名#
Git alias with #
我试图创建一个带有 # 的别名,但发现我做不到。
别名:
ignored = !sh -c -e -v "cat .gitignore .git/info/exclude $HOME/.config/git/ignore | grep -v `#` | grep ."
我已经找到了一个更好的方法来做到这一点(find -type f | git check-ignore --stdin
- 在 repo 中忽略了文件,而不仅仅是模式)但我仍然很好奇我怎样才能避免 git 思考 "oh, it's a # the rest must be a comment" 并忽略它。我尝试了各种引号(反引号、双引号和单引号、斜杠)但没有任何效果。在 shell 中,该命令当然有效。
所以,问题是:如何在 shell(sh -c
或函数)别名中的 git 配置文件中使用散列,以便它实际上不被视为评论?
以下变体适用于我:
ignored = !"cat .gitignore .git/info/exclude $HOME/.config/git/ignore | grep -v '#' | grep ."
即没有第 3 个 shell,#
周围有单引号。
我试图创建一个带有 # 的别名,但发现我做不到。
别名:
ignored = !sh -c -e -v "cat .gitignore .git/info/exclude $HOME/.config/git/ignore | grep -v `#` | grep ."
我已经找到了一个更好的方法来做到这一点(find -type f | git check-ignore --stdin
- 在 repo 中忽略了文件,而不仅仅是模式)但我仍然很好奇我怎样才能避免 git 思考 "oh, it's a # the rest must be a comment" 并忽略它。我尝试了各种引号(反引号、双引号和单引号、斜杠)但没有任何效果。在 shell 中,该命令当然有效。
所以,问题是:如何在 shell(sh -c
或函数)别名中的 git 配置文件中使用散列,以便它实际上不被视为评论?
以下变体适用于我:
ignored = !"cat .gitignore .git/info/exclude $HOME/.config/git/ignore | grep -v '#' | grep ."
即没有第 3 个 shell,#
周围有单引号。