【发布时间】:2018-08-01 05:03:53
【问题描述】:
我在 git config 中有以下别名以进行漂亮的格式化
$ git config alias.lp '!git log --pretty=format:"%h - %an (%ar): %s"'
它用于其他别名,这里是正确工作的例子:
$ git config alias.la '!f(){ git lp -20 --author="${1-Baur}"; }; f'
$ git config alias.lm '!f(){ git lp --grep "${1-strange}"; }; f'
$ git config alias.lf '!git lp --follow'
但我找不到如何实现别名以查看上游提交的方法。
这行得通:
$ git log --pretty=format:"%h - %an (%ar): %s" HEAD..@{u}
这不起作用:
$ git lp HEAD..@{u}
带有错误信息:
fatal: ambiguous argument 'HEAD..@u': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
如您所见,HEAD..@{u} 变成了HEAD..@u,大括号丢失了。
启用$ GIT_TRACE=1后:
$ git lp HEAD..@{u}
21:17:32.678084 git.c:560 trace: exec: 'git-lp' 'HEAD..@{u}'
21:17:32.679097 run-command.c:626 trace: run_command: 'git-lp' 'HEAD..@{u}'
21:17:32.683098 run-command.c:626 trace: run_command: 'git log --pretty=format:"%h - %an (%ar): %s"' 'HEAD..@{u}'
21:17:32.726084 git.c:328 trace: built-in: git 'log' '--pretty=format:%h - %an (%ar): %s' 'HEAD..@u'
fatal: ambiguous argument 'HEAD..@u': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
我应该如何在 Windows 上的 git bash 中转义 git lp HEAD..@{u} 中的花括号?
[更新]
感谢 @phd 指出在 linux 上没有问题!
我检查了这个转义问题只在 Windows 上的 git bash 上。
原生ubuntu和windows上的ubuntu都没有这个问题。
但我必须使用windows版本。所以我还在寻找解决方案。
$ git --version
git version 2.14.1.windows.1
【问题讨论】: