Exit Vim without committing changes in Git

后端 未结 4 1227
深忆病人
深忆病人 2020-12-24 10:42

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 chang

4条回答
  •  心在旅途
    2020-12-24 11:18

    When you haven't made changes and saved them, :q! could suffice (in a plain commit; when you're not amending), but if you are like me, chances are you've already (even unconsciously) persisted the edited message.

    Git (and other such tools that use Vim to edit a message) will abort the entire process (and ignore any saved changes to the message) if the editor quits with a non-success exit status. You can do that in Vim with the :cq[uit]! command.

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

提交回复
热议问题