git log 以及提交消息正文中的其他详细信息

发布于 2024-11-19 15:04:29 字数 352 浏览 10 评论 0原文

我有一个 git 提交模板,如下所示:

[overtype with subject line up to 50 chars ----->]

[overtype with details of what's in the commit]

[other information]
Ticket-Refs: 

我想将“Ticket-Refs:”后面的字符串附加到 git 日志图 --pretty=format:

我试图使用 --grep= 要在 %b%B 上实现此目的,我们将不胜感激。

I have a git commit template as below:

[overtype with subject line up to 50 chars ----->]

[overtype with details of what's in the commit]

[other information]
Ticket-Refs: 

I would like to append the string after "Ticket-Refs:" to a git log graph --pretty=format:

I was trying to use the --grep= to achieve this on the %b or %B, any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白馒头 2024-11-26 15:04:29

绝对不是最优雅的方式,但这里有一个选项:

$ git log --graph --grep=Ticket-Refs --pretty=format:'DELIMITER_STRING%B' | grep '\*.*DELIMITER_STRING\|Ticket' | sed s/DELIMITER_STRING.*//

或者另一个选项

$ git log --graph --grep=Ticket-Refs --pretty=format:'DELIMITER_STRING%b' | grep '\*.*DELIMITER_STRING\|Ticket-Refs' | sed ':a;N;$!ba;s/DELIMITER_STRING.*Ticket-Refs://'

我无耻地从 另一篇文章

Definitely not the most graceful way, but here is an option:

$ git log --graph --grep=Ticket-Refs --pretty=format:'DELIMITER_STRING%B' | grep '\*.*DELIMITER_STRING\|Ticket' | sed s/DELIMITER_STRING.*//

Or another option

$ git log --graph --grep=Ticket-Refs --pretty=format:'DELIMITER_STRING%b' | grep '\*.*DELIMITER_STRING\|Ticket-Refs' | sed ':a;N;$!ba;s/DELIMITER_STRING.*Ticket-Refs://'

I shamelessly stole some of the code for the second option from another post

猛虎独行 2024-11-26 15:04:29

我知道我没有给出确切的答案,但是如果您可以将 Ticket-refs 部分移至 git Notes ,即使用如下所示的方式向提交添加注释:

git notes add sha -m "Ticket-refs:blah"

那么您可以轻松地绘制图表像你想要的那样记录:

git log --graph --format="%N"

否则,我不确定是否可以单独提取该部分,然后将其与图表一起使用。

I know I am not giving an exact answer, but if you can move the ticket-refs part to git notes, that is add notes to the commits using something like below:

git notes add sha -m "Ticket-refs:blah"

then you can easily do the graph log like you want:

git log --graph --format="%N"

Otherwise, I am not sure if it is possible to extract that part alone and then use it with the graph.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文