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

Question

I am using Git. I did a pull from a remote repo and got an error message:

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

I try to type a message and press Enter but nothing happens.

How do I tell Git/Terminal I am done typing in my message?

I am using Terminal on OS X.

Answer

The commit message is from Git, but it is actually the editor that keeps you from quitting. This is because Git uses your default editor, which for a variety of reasons is usually set to vi (it might be something else on your OS, like pico).

To write a commit message and get out of VI, follow these steps:

  1. press i (i for insert)
  2. write your merge message
  3. press esc (escape)
  4. write :wq (write & quit)
  5. then press enter

You can also configure Git to use another editor to avoid having to use VI (or its close cousin VIM).

Is there any way to git checkout previous branch?

Find size of Git repository