git 的 --pretty 选项字符串格式的别名
An alias for git's --pretty option string format
我知道我可以为 git log
使用很多参数的调用设置别名。
例如,我可以使用这个:
git config --global alias.lg "log --graph --pretty=format:'%h -%d %s (%cr) <%an>'"
使用更短的 git lg
别名 git log --graph --pretty=format:'%h -%d %s (%cr) <%an>'
。
是否可以单独为 --pretty=format:
字符串设置别名?这样我就可以输入
git log --pretty=my_aliased_format
The git log
documentation has this to say about the --pretty[=<format>]
and --format=<format>
options (the --format
one has a required <format>
name while --pretty
has an optional one). This text is buried fairly far in, under 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 log
使用很多参数的调用设置别名。
例如,我可以使用这个:
git config --global alias.lg "log --graph --pretty=format:'%h -%d %s (%cr) <%an>'"
使用更短的 git lg
别名 git log --graph --pretty=format:'%h -%d %s (%cr) <%an>'
。
是否可以单独为 --pretty=format:
字符串设置别名?这样我就可以输入
git log --pretty=my_aliased_format
The git log
documentation has this to say about the --pretty[=<format>]
and --format=<format>
options (the --format
one has a required <format>
name while --pretty
has an optional one). This text is buried fairly far in, under 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
设置为别名更为典型和常规,就像您之前的示例一样,但这也很有效。