Exit Vim without committing changes in Git

j0fb picture j0fb · May 16, 2013 · Viewed 14.4k times · Source

When I use git commit --amend or git rebase -i, vim opens up for me to make changes. If I then change my mind and exit vim without making any changes, a commit is still made which shows up in git reflog.

How do I exit the editor without committing anything?

Answer

EDY ARMENDARIZ picture EDY ARMENDARIZ · Jan 16, 2014
:cq!

This will force an error to Vim and it will not save any changes. Link to Vim manual.

You may want to use cq without ! if you want vim to exit with an error and without saving.