Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid "Merge branch 'name_of_branch' in commit messages?

Tags:

git

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?

like image 279
Sandra Schlichting Avatar asked Aug 29 '10 13:08

Sandra Schlichting


People also ask

How do I stop git from merging messages?

press "esc" (escape) write ":wq" (write & quit)

How do I stop a branch from merging?

Use git-reset or git merge --abort to cancel a merge that had conflicts. Please note that all the changes will be reset, and this operation cannot be reverted, so make sure to commit or git-stash all your changes before you start a merge.


1 Answers

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.)

like image 156
Cascabel Avatar answered Oct 04 '22 02:10

Cascabel