【问题标题】:how do you list git commits with their tags interleaved in the output?你如何列出 git 提交,它们的标签在输出中交错?
【发布时间】:2018-01-11 19:20:13
【问题描述】:

我有一些代码得到很多提交并且也经常被标记。

我想看看每个标签的提交是什么,然后我会在标签之间做一个 git diff 来查看实际的代码更改。

如何列出 git 提交及其标签在输出中交错?


我在想这样的输出可以让我看到每个标签的提交:

${short_commit_hash} ${commit_date} ${first_line_of_text_from_commit_message}
${short_commit_hash} ${commit_date} ${first_line_of_text_from_commit_message}
${short_commit_hash} ${commit_date} ${first_line_of_text_from_commit_message}
${tag_name} ${tag_date}
${short_commit_hash} ${commit_date} ${first_line_of_text_from_commit_message}
${short_commit_hash} ${commit_date} ${first_line_of_text_from_commit_message}
${short_commit_hash} ${commit_date} ${first_line_of_text_from_commit_message}
${tag_name} ${tag_date}

然而,这个输出并不是一个严格的要求。这只是我想出的一个想法,它可以帮助我查看每个标签的提交内容。

可能有一些简单的 git 命令已经完成了我所要求的大部分工作,并且这些命令可能非常简单/直接。

【问题讨论】:

  • git log --format=format:'%h %ci %s%n%D' 让您完成 90% 的路程。

标签: git diff tagging


【解决方案1】:

你真的不希望标签交错。您希望在标记之前的日志格式中有一个换行符。考虑到这一点,只需执行以下操作:

git log --format=format:'%h %ci %s%+D'

来自git-log 文档:如果在占位符的 % 之后添加 +(加号),当且仅当占位符扩展为非空字符串时,才会在扩展之前立即插入换行符。

【讨论】:

    猜你喜欢
    • 2017-12-19
    • 2018-09-20
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    • 2016-07-30
    • 2019-04-04
    • 1970-01-01
    • 2019-11-09
    相关资源
    最近更新 更多