我在git配置中使用了以下别名来进行格式化
$ 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'
但我找不到如何实现alias来查看上游提交的方法。
这是有效的:
$ 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>...]'
我该怎么摆脱花括号
git lp HEAD..@{u}
在windows上的git bash中?
[更新]
多亏了
@博士
为了指出linux上没有问题!
我检查了这个转义问题是否只出现在windows上的git bash上。
windows上的本地ubuntu和ubuntu没有这个问题。
但我必须使用windows版本。所以我还在寻找解决办法。
$ git --version
git version 2.14.1.windows.1