Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to abort 'git commit --amend'?

Tags:

git

I accidentally used git commit --amend. My text editor is open and waiting for input. I know, that when I close it now (not changing the existing commit message) the commit will be amended. What can I do to abort the process?

This blog article says that I can simply delete the commit message and the commit will then not be valid and ignored. Is that correct? Are there alternatives?

like image 835
Flip Avatar asked Dec 01 '16 09:12

Flip


People also ask

How do I save and exit an amend git commit?

Typing :wq and pressing enter should do it, i.e. save the commit message and exit.

How do I escape a commit?

On the first line, write your commit message and hit esc to switch back to normal mode. Type :wq to save and exit the editor. Hit enter to return to the normal terminal window.

What is commit amend in git?

Changing the Last Commit: git commit --amend. The git commit --amend command is a convenient way to modify the most recent commit. It lets you combine staged changes with the previous commit instead of creating an entirely new commit.

Can I push amended commit?

Adding more changes to the latest commit using amend. It is also possible to add more changes to the recent commit using amend. So that you don't need to add a new commit for missed out changes. First, you have to add the files and then you can use -amend to add those changes to the last commit.


1 Answers

That is correct. Saving the file with no contents will abort the amend.

like image 130
djb Avatar answered Oct 07 '22 00:10

djb