0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

How to cancel Git | commit --amend prematurely (cancel while entering commit message)

Last updated at Posted at 2019-04-16

problem

Amend it!

$ git commit --amend

I want to quit after all!

 Fix you brain # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # ... 

Get out without saving!

:q! (The vim command)

Wow ah, it has been committed ah!

  Date: Fri Dec 18 13:38:52 2015 +0900 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 you-need-amend.rb create mode 100644 but-i-walk-my-way.sh 

Solution 1

commit --amend

1. Delete all commit messages.

Make no commit message. (Comments may be included)

 # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Dec 18 13:38:52 2015 +0900 

However. Because it will be committed if there is only one blank line / comment line. It would be safer to delete all the file contents. (If you keep pressing the d key as well)

2. End saving

:x (the vim command)

3. Results

Not committed (Return to the original)

 Aborting commit due to empty commit message. 

Solution 2

image

How is it usually?

In a normal commit that is not amend. It just seems OK if you exit without saving. ( :q! )

environment

  • git version 2.3.8 (Apple Git-58)
  • vim 7.3

Aside

I noticed later that it was clearly explained in the commit editing message.

an empty message aborts the commit.

Original by

Git | commit --amend を途中で取り消しする方法 (コミットメッセージ入力中のキャンセル)

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?