如何在提交消息中避免“合并分支'name_of_branch'? [英] How to avoid "Merge branch 'name_of_branch' in commit messages?

查看:270
本文介绍了如何在提交消息中避免“合并分支'name_of_branch'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记得大约一年前,我做了一些合并,导致提交消息在远程存储库上的 Merge branch'Name_of_branch'



从我记得的情况来看,如果我重新分支了一个分支中的所有提交,然后将它合并到master然后推送到远程存储库,就会发生。



但现在我不能用git-1.7.2.2来重现它。



它已被修复吗?或者可以有人解释这是怎么发生的,或许该如何避免它?解析方案

这是默认合并提交消息。它不需要任何特别的东西来获得它 - 只需要做任何不寻常的合并到master:

   -  o  -  o  -  X( master)
\ /
o - o(topic)

提交X的消息将是合并分支主题。如果你合并成master以外的分支,默认的消息是Merge branch'< merged-branch>'到'< branch>'



我不确定你为什么要问修复和避免这个问题。这是合并提交的非常合理的默认消息。如果您想要更详细的合并提交信息,欢迎您提供一个。 (两种主要方式是使用 git merge --no-commit ,后面跟着 git commit git merge 后跟 git commit --amend 来编辑邮件。)



也许你习惯只做快进合并? (这些都是微不足道的合并,你正在合并的提交将你当前的分支作为祖先,所以所有git必须做的是通过历史记录向前移动分支。)那些不会生成合并提交,所以没有提交消息。 / p>

(顺便说一下,推送与此无关 - 它只是将信息从一个仓库复制到另一个仓库,它不会创建提交。) p>

I remember that for about a year ago I did some merges that resulted in the commit messages being Merge branch 'Name_of_branch' on the remote repository.

From what I remember it would happen if I rebased all commits in a branch and then merged it to master and then pushed to remote repository.

But now I can't reproduce it with git-1.7.2.2.

Have it been fixed? Or can someone explain how this happens, and perhaps how to avoid it?

解决方案

That's a default merge commit message. It doesn't take anything special to get it - just do any nontrivial merge into master:

- o - o - X (master)
   \     /
    o - o (topic)

The default commit message for commit X will be "Merge branch 'topic'". If you merge into a branch other than master, the default message is "Merge branch '<merged-branch>' into '<branch>'".

I'm not sure why you're asking about "fixing" and "avoiding" this. It's a very reasonable default message for a merge commit. If you'd like a more detailed merge commit message, you're certainly welcome to provide one. (The two primary ways are to use git merge --no-commit followed by git commit, or git merge followed by git commit --amend to edit the message.)

Perhaps you're used to doing only fast-forward merges? (Those are trivial merges, where the commit you're merging has your current branch as ancestor, so all git has to do is move the branch forward through history.) Those don't generate merge commits, so there's no commit message.

(By the way, pushing has nothing to do with this - all it does is copy information from one repo to another. It doesn't ever create commits.)

这篇关于如何在提交消息中避免“合并分支'name_of_branch'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆