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?
Typing :wq and pressing enter should do it, i.e. save the commit message and exit.
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.
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.
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.
That is correct. Saving the file with no contents will abort the amend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With