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:
- press
i(i for insert) - write your merge message
- press
esc(escape) - write
:wq(write & quit) - then press enter
You can also configure Git to use another editor to avoid having to use VI (or its close cousin VIM).
Answer from Saad.elzwawy on Stack OverflowThe 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:
- press
i(i for insert) - write your merge message
- press
esc(escape) - write
:wq(write & quit) - then press enter
You can also configure Git to use another editor to avoid having to use VI (or its close cousin VIM).
Actually it's not an error! It means you should enter some message to mark this merge.
My OS is Ubuntu 14.04. If you use the same OS, you just need to do this as follows:
Type some message
CtrlCO
Type the file name (such as "Merge_feature01") and press Enter
CtrlX to exit
Now if you go to .git and you will find the file "Merge_feature01", that's the merge log actually.
This is depend on the editor you're using.
If vim 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):
[user]
name = somename
email = [email protected]
[core]
editor = vim
excludesfile = /home/mypath/.gitignore_global
[color]
ui = auto
# other settings here
The answer marked correct here did not work for me as after you quit the editor with wq or :q!, the file gets saved and the merge happens.
The alternative, I've found for now is to suspend the vim process by using a Ctrl + Z and then aborting the merge with a git merge --abort and then killing the background process (you'll see the PID when you do the Ctrl + Z)
Whenever I try to merge a branch, I get the following screen prompting me to add a message. When I try to add a message I can only use up and down keys and I can't enter any text. Also, I'm not sure how to submit it so that the screen prompt goes away and back to the normal terminal. Any help would be appreciated, thanks.
It seems you are now in vi or vim.
press i, then input your merge message.
Then esc, and :wq
You are probably using VI as your editor. You can do two things: press 'i', or 'a', and you will be entering type mode, which can be exited using the ESC key, and then press ':wq', or 'ZZ', which will save the file.
An alternative is probably to use the -m switch on the command line, which will allow you to skip this screen, and supply a message immediately (-m "My message here")