Reputation: 299
I'm learning using Git on an OS X Terminal. It seems really easy. But I can't handle just one problem: When I try to merge two branches, for example "myTestBranch" into "master" this program covers the terminal and shows me a new view where I should write the merge message. And then, I don't know how to do "Enter", save the merge message and then come back to the main terminal view where I can continue working.
Does anyone know, how does it work?
Upvotes: 29
Views: 32808
Reputation: 921
If you haven't change the default git's editor, that "new view" is the Vi program.
To save your commit message using Vi, follow the next steps:
i
ESC
key:wq
Typing :q
, step 4, is not enough beacuse just means QUIT without saving. That's why you need :wq
, which means WRITE and QUIT.
You can write your commit message using your favourite editor(vim, emacs, etc.). To achieve this, you can use configuration parameter or environment variables, listed in order:
Using the configuration option type something like this:
$git config --global core.editor "nano"
Or if you want to use enviroment variables, add something like this to your .bash_profile
$export GIT_EDITOR="PATH/TO/YOUR/EDITOR"
Upvotes: 54
Reputation: 586
By default Git will open Vim as editor.
You basically need to type 'I' to start editing. After that ESC
and type :q
to quit or :w
to save the file. You can also combine them: :wq
to save and exit Vim.
For more information about Vim check the official documentation
To change Vim for any other editor check the Git Environment Variables or older posts with a similar question: How do I make Git use the editor of my choice for commits?
Upvotes: 16