我知道我可以设置一个别名有很多的参数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:
有几个内置的格式,你可以通过设置一个漂亮的定义更多格式<名>配置选项要么另一种格式的名称,或格式:字符串,如下所述(见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
作为别名,如您刚才的例子,但是这个工作也很好。