我知道我可以为 git log
设置别名带有大量参数的调用。
例如,我可以使用这个:
git config --global alias.lg "log --graph --pretty=format:'%h -%d %s (%cr) <%an>'"
别名git log --graph --pretty=format:'%h -%d %s (%cr) <%an>'
更短git lg
.
是否可以为 --pretty=format:
设置别名单独串?这样我就可以输入
git log --pretty=my_aliased_format
最佳答案
The git log
documentation关于 --pretty[=<format>]
有这样的说法吗?和--format=<format>
选项(--format
有一个必需的 <format>
名称,而 --pretty
有一个可选名称)。这段文字被埋在很远的地方,在 the section PRETTY FORMATS 下。 :
There are several built-in formats, and you can define additional formats by setting a pretty.<name> config option to either another format name, or a format: string, as described below (see git- config(1)). ...
因此:
$ git config pretty.foo 'bar %H baz' # you might want --global here
$ git log --format=foo | head -3
bar b5101f929789889c2e536d915698f58d5c5c6b7a baz
bar a562a119833b7202d5c9b9069d1abb40c1f9b59a baz
bar 7fa92ba40abbe4236226e7d91e664bbeab8c43f2 baz
只需根据该部分中列出的指令编写您自己的格式,为其命名,然后将该名称放入您的配置(本地或全局)中,然后 --format=<name>
将访问它。
比较典型和常规的是设置lg
作为别名,如前面的示例所示,但这也很有效。
关于git - git 的 --pretty 选项字符串格式的别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54643839/