I am using Git Bash and am trying to figure out what is happening when I type 'git commit -a'.
Looks like VIM opens up to edit my commit message but how do I save and actually complete this commit? I type in the editor and hit enter but it just creates another line.
FYI: I am using VM Fusion on my mac so some of my keys might be a little different
this is a question about VIM and not git itself (if i'm not mistaken)
VIM uses multiple modes, to exit insert mode hit ESC or ^C. to save and exit the file use ZZ
, :x
or :wq
just to be complete: git commit -a
will first add all tracked and changed files' contents to the index and then creates a commit (after specifying the commit message inside vim – or your editor of choice)
Just leave VIM (command mode -> :wq
).
-a
flag works like:
git add -u git commit ...
-m
flag specifies commit message. That message is mandatory so if you don't pass that (git commit -m "My message"
) the default text editor will be opened (you can change it in git configuration) and you'll have to write a commit message, then save and quit the editor.
To save your commit you save and exit the file as you normally would in vim.
:wq
If you change your mind and want to abort you exit without saving.
:q!
You don't have to use VIM though, you can set the editor, for example the following would change the editor git uses to textmate.
git config --global core.editor textmate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With