git - 如何自定义 git 的 merge 提交消息?

标签 git git-merge

每次我进行 merge 时,我都需要生成一个 merge 提交,我希望它不仅仅包含所有提交的摘要。

我的问题是如何格式化 git-fmt-merge-msg 或由什么决定此自动消息(我可以在提交后通过修改它并使用 git-log --pretty 手动执行此操作=格式:'...')

例如我想这样格式化它:

 Merge branch 'test'  
    * test:  
      [BZ: #123] fifth commit subject  
      [BZ: #123] fourth commit subject  
      [BZ: #123] third commit subject  
      [BZ: #123] second commit subject  
      [BZ: #123] first commit subject  

 __________________________________________
 Merge details:  
     [BZ: #123] fifth commit subject  
               at 2010-06-30 11:29:00 +0100  
       - fifth commit body  

     [BZ: #123] fourth commit subject  
               at 2010-06-30 11:22:17 +0100  
       - fourth commit body  

     [BZ: #123] third commit subject  
               at 2010-06-30 11:21:43 +0100  
       - third commit body  

     [BZ: #123] second commit subject  
               at 2010-06-30 11:21:30 +0100  
       - second commit body  

     [BZ: #123] first commit subject  
               at 2010-06-30 11:29:57 +0100  
       - first commit body

最佳答案

我知道这并没有回答最初的问题,但是为了像我这样访问此页面的 git 新手的利益,因为它是目前“git change merge commit message”的第一个 Google 结果,我会提到可以:

git commit --amend -m"New commit message"

更改 merge 提交的提交消息而不丢失与 merge 提交的任何父级的链接。

关于git - 如何自定义 git 的 merge 提交消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3148863/

相关文章:

git - 为什么 merge 这些分支没有任何作用?

Git 在更新时默默地 merge 应该发生冲突的内容

git - 从 Git 存储库生成统计信息

git-flow 完成发布 - 选择性 merge

Git rebase,跳过 merge 提交

git - 基于两个未 merge 的分支在分支上工作

git - 我可以与它的前辈之一压缩 merge 提交吗?

git read-tree 删除了所有历史记录

git - Intellij Idea 能否自动暂存变化

git - Git 如何在多次提交中存储大文件?