gpt4 book ai didi

git - git log 格式的可选缩进换行符

转载 作者:太空狗 更新时间:2023-10-29 13:36:00 25 4
gpt4 key购买 nike

我一直在修补git一些的别名 log命令。我拥有大部分我想要的东西 ( credit here ),但我在一件事情上遇到了麻烦。当我打电话时……

git log --graph --format=format:'%h - [%ar] %s%+d'

……我明白了……

* ab123f - [6 hours ago] Fix the references
| (HEAD, origin/master, master)
* bc123f - [8 hours ago] New build syntax
* cd123f - [10 hours ago] Initial import

…哪里%+d添加一个新行并放置 --decorate标签(如果存在)。我宁愿让标签与时间戳一致,像这样:

* ab123f - [6 hours ago] Fix the references
| (HEAD, origin/master, master)
* bc123f - [8 hours ago] New build syntax
* cd123f - [10 hours ago] Initial import

我该如何实现?如果没有 --decorate,我不想要额外的换行符标签。我一直在尝试各种 format placeholders: %+d , %-d , %+ d (这不起作用); %>(<N>) 的排列, %>>(<N>) ;等等,但我无法让它做我想做的事。

为简单起见,颜色和进一步的提交信息已被删除,但它们似乎会干扰 torek's answer .完整命令如下:

git log --graph --format=format:'%C(bold yellow)%h%C(reset) - %C(green)(%ar)%C(reset) %s %C(white)<%an>%C(reset)%C(auto)%+d%C(reset)'

最佳答案

%w 如下所示似乎可以解决问题。

git log --graph --format=format:'%h - [%ar] %-s%w(0,0,9)%+d'

Git 版本 1.8.5.2

关于git - git log 格式的可选缩进换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22415347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com