我真的很喜欢简短的 git 日志格式,我可以在其中看到作者、日期和更改描述,如下所示:
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
哪些输出:
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
(来自stackoverflow问题“link text”)
现在的问题是,如何在我的机器上将其保存为新格式,这样我只需要编写类似的内容,例如:
git log --format=jespers_favourite
最佳答案
在较新版本的 Git 中(已通过 v1.7.8 确认),可以使用 git config pretty.named_format
设置 命名的 pretty-print 日志格式 .这些可以使用<file-option>
在机器范围、用户或文件级别进行设置论据。
创建名为 jespers_favourite
的日志格式或整机使用--system
git config --system pretty.jespers_favourite "%h%x09%an%x09%ad%x09%s"
对于单用户使用'--global'
git config --global pretty.jespers_favourite "%h%x09%an%x09%ad%x09%s"
离开<file-option>
参数空白将默认设置当前存储库的配置文件,.git/config
除非另有定义。
关于Git如何保存预设的git log --format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1441156/