I'm using git. I did a normal merge, but it keeps asking this:

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.

And even if I write something, I can't exit from here. I can't find docs explaining this. How should I do?

  • 2
    press ESC :wq it's a vim syntax ;) – demonking Jan 27 '15 at 8:47

This is depend on the editor you're using.

If you can use ESC and :wq or ESC and Shift+zz. Both command save file and exit.

You also can check ~/.gitconfig for editor, in my case (cat ~/.gitconfig):

    name = somename
    email = somemail@gmail.com
    editor = vim
    excludesfile = /home/mypath/.gitignore_global
  ui = auto
  # other settings here

I know this may be late, however I have noticed that it only occurs if I make a commit to a branch is a bit more updated than the branch that i'm merging.

Image to help with understanding

It turns out that if I change a branch (i.e., add more files to the branch), and try and merge another branch into it, Git will request me to write a MERGE_MSG for that branch.

In this image, it shows that I added a LICENSE file in master and a .gitignore file in branch npm-init.

Because master contains a new file, LICENSE, and npm-init does not know about it, Git asked me to write a message about why I should merge it.

Similarly, I merged add-eslint into add-dev before I merged the changes in install-deps.

I know this may be hard to understand (even for me at first), but I hope the image clears things up :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.