Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a large message on git merge?

Tags:

git

I would like to do a git merge to plough the work of one branch back into another.

However, since a lot has been done and I'm going to do a no-fast-forward merge I would like the commit to contain extensive information about what's in the merge.

If I were doing a normal commit I could use the -m flag and an editor would be fired up for me to put the details into (edit this is incorrect - see below). However if I use the -m flag during commit it simply tells me that the message requires content:

$ git merge development --no-ff -m
error: switch `m' requires a value

Since I have a fairly large merge message, I would prefer an editor rather than a single line string. How can I get that though?

EDIT

Although the answers have covered my question I realised that using the -m flag during a normal commit does not in fact fire up the editor (although -a does if you're creating a tag). The only way I've to get the editor during a normal commit it to simply type commit with no other flags or options.

like image 716
Peter Nixey Avatar asked Sep 13 '11 11:09

Peter Nixey


People also ask

How do I leave a merge message in git?

Press “esc” (escape) Write “:wq” (write & quit)

What is the best git merge strategy?

The most commonly used strategies are Fast Forward Merge and Recursive Merge. In this most commonly used merge strategy, history is just one straight line. When you create a branch, make some commits in that branch, the time you're ready to merge, there is no new merge on the master.


2 Answers

Use the --no-commit flag, and then type git commit - you'll be able to edit the message then:

git merge development --no-ff --no-commit
git commit

Alternatively, if you've already done the merge, you can amend the merge commit to change its message with:

git commit --amend
like image 67
Mark Longair Avatar answered Oct 11 '22 08:10

Mark Longair


Perform the commit as usual and change the commit message afterwards using git commit --amend.

like image 43
Bombe Avatar answered Oct 11 '22 08:10

Bombe