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

后端 未结 3 1343
隐瞒了意图╮
隐瞒了意图╮ 2021-01-29 17:46

I have asked Git to perform a commit from within git bash, It has brought up VI as it always does.

I now wish to cancel the commit, how do I prevent proceeding with the

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 18:30

    To sum up:

    • When creating a new commit (i.e git commit) quit using :q!.
    • When amending (i.e. git commit --amend) remove the commit message (only the first few rows not beginning with a #) for example by holding v and using arrow keys to select it and then pressing Delete. Quit with :wq to apply changes! If you use :q! the changes will be lost and the previous commit message will be used.

    When using VIM it's ok in both cases to quit with :cq - VIM will quit with an error code and the commit will be aborted.

提交回复
热议问题