I’m new with git, so I decided to learn git using the tutorials of github. The third chapter said:
“For this first example we’ll modify the README file to add ourselves as an author on the project. So we simply edit the file. Now we want to commit that change, so we run the
git commit -acommand.”
When I use the
git commit -a command, the console opens a vim and I wrote my message, but I don’t know how to close this vim editor from the console. How do I save the message and close vim?
- In vim, you save a file with :wEnter while in the normal mode (you get to the normal mode by pressing Esc).
- You close your file with :q while in the normal mode.
You can combine both these actions and do Esc:wqEnter to save the commit and quit vim.
As an alternate to the above, you can also press ZZ while in the normal mode, which will save the file and exit vim. This is also easier for some people as it’s the same key pressed twice.