Git如何保存预设的git log --format [英] Git how to save a preset git log --format

查看:277
本文介绍了Git如何保存预设的git log --format的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  git log 

我很喜欢简短的git log格式,在这里我可以看到作者,日期和更改描述。 --pretty = format:%h%x09%an%x09%ad%x09%s

哪些输出:

  fbc3503 mads Thu Dec 4 07:43:27 2008 +0000显示mobile if phone is null ... 
ec36490 jesper Wed Nov 26 05:41:37 2008 +0000 [942]之后清理:使用timezon
ae62afd tobias星期二11月25日21:42:55 2008 +0000固定#67加入时区supp
164be7e mads星期二11月25日19:56:43 2008+0000固定测试,和一个'无休止的appoi

(从stackoverflow问题

  git log --format = jespers_favourite 


考虑git log手册页提到:

$ p $ - pretty [=< format>]
--format [= < format>]




漂亮地打印提交日志的内容在一个给定的格式,其中可以是在线,短,中,全,完整,电子邮件,原始和格式之一:。

< format> 只能有预定义的值。

这只能让你有可能
定义一个别名 作为该命令的快捷方式。

  [别名] 
jespers_favourite = log --pretty = format:%h%x09%an%x09% ad%x09%s



<$ $ b $ [别名]
compactlog = log --pretty = format:%h%x09%an%x09%ad%x09%s


I really like the short git log format where I can see author, date and change description like this:

git log --pretty=format:"%h%x09%an%x09%ad%x09%s"

Which outputs:

  fbc3503 mads    Thu Dec 4 07:43:27 2008 +0000   show mobile if phone is null...   
  ec36490 jesper  Wed Nov 26 05:41:37 2008 +0000  Cleanup after [942]: Using timezon
  ae62afd tobias  Tue Nov 25 21:42:55 2008 +0000  Fixed #67 by adding time zone supp
  164be7e mads    Tue Nov 25 19:56:43 2008 +0000  fixed tests, and a 'unending appoi

(from stackoverflow question "link text")

Now, the question is, how do I save this as a new format on my machine so I only have to write something like, for instance:

git log --format=jespers_favourite

解决方案

Considering the git log manual page mentions:

--pretty[=<format>]
--format[=<format>]

Pretty-print the contents of the commit logs in a given format, where can be one of oneline, short, medium, full, fuller, email, raw and format:. When omitted, the format defaults to medium.

the <format> can only have predefined values.
That only leaves you the possibility to define an alias as a shortcut for that command.

[alias]
        jespers_favourite = log --pretty=format:"%h%x09%an%x09%ad%x09%s"

or

[alias]
        compactlog = log --pretty=format:"%h%x09%an%x09%ad%x09%s"

这篇关于Git如何保存预设的git log --format的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆