13

I am trying to do a git merge through the terminal. I was working on branch fix_stuff and I need to merge back into develop. So I do as follows

git checkout develop
git merge --no-ff fix_stuff

Now it takes me to seemingly a text editor -- still within the terminal -- that has the following message

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

Sure enough I press i and then entered my message. Now that I am done with the message, I don't know how to proceed. I tried esc x then esc q. Nothing.

I am using Android Studio terminal through Mac El Capitan

Varun
  • 33,833
  • 4
  • 49
  • 42
Nouvel Travay
  • 6,292
  • 13
  • 40
  • 65
  • 1
    See [this question](http://unix.stackexchange.com/questions/181280/how-to-exit-a-git-merge-asking-for-commit-messagehttp://unix.stackexchange.com/questions/181280/how-to-exit-a-git-merge-asking-for-commit-message). You can also config a different merge tool, see [this question](http://stackoverflow.com/questions/137102/whats-the-best-visual-merge-tool-for-git) – Xiongbing Jin Feb 27 '16 at 00:44
  • you can update-and-quit with `:x` – jthill Feb 27 '16 at 07:00
  • https://stackoverflow.com/questions/13239368/git-how-to-close-commit-editor – pkamb Oct 05 '20 at 23:57

3 Answers3

25

Because you pressed i to enter your text, I think that editor is vim. Assuming that you typed in your commit message ok, you have to do

<esc> :w <enter>

to write to the file and

<esc> :q <enter>

to quit. Note: things in <> denote key presses.

intboolstring
  • 6,891
  • 5
  • 30
  • 44
6

Press Esc, next type ":wq" and press Enter

ORIOLmendivil
  • 61
  • 1
  • 2
0

If you have set vim as your editor, vim is launched to request you to enter your commit message after git merge --no-ff.

After you entered your commit message, you need to save message and exit vim.

There are two ways to save and exit vim

1. Esc key to switch to command mode, then enter

:w
:q

2. Ctrl+z twice.

gzh
  • 3,507
  • 2
  • 19
  • 23
  • IIRC correctly, you answered this well after me. This is almost exactly what I said. – intboolstring Feb 28 '16 at 20:41
  • @intboolstring I admit I get hints from your answer, thank you. but the command you provided to use vim is not correct and incomplete, IMHO. – gzh Feb 28 '16 at 22:11
  • @intboolstring is not necessary for vim in command mode. – gzh Feb 28 '16 at 22:33