How do I stop a Git commit when VI is on the screen waiting for a commit message?

You have two options:

  • Provide an empty commit message. If it’s a new commit and you haven’t yet saved the message, you can simply use :q! (quit without saving). If you’ve already saved (or you’re amending a previous commit), just delete the entire log message and save again. This can be done with ggdG + :wq in Vim.

  • Have the editor exit with a non-zero exit code. In Vim, you can use :cq (quit with an error code).

It’s worth noting that you can always reset your working copy to the state it was in before the commit with git reset HEAD^.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)