How to abort a git commit amend

Some­times you issue a git com­mit –amend only to real­ize that you didnt really mean to amend the pre­vi­ous com­mit. You’d rather save your changes as a new com­mit. This can hap­pen under many cir­cum­stances like chang­ing your mind at the last moment or acci­den­tally issu­ing the com­mand from the com­mand line history.

There are 2 ways to abort a com­mit amend with­out sav­ing changes

  1. If vi edi­tor is the one that opens up to amend your com­mit mes­sage, you can sim­ply press ESC + : + c + q + !
  2. If you are using any other edi­tor, you dont have the option to use that short­cut, but you could always erase the com­mit mes­sage. That makes git think that you are try­ing to com­mit with a blank com­mit mes­sage and it there­fore aborts with­out saving.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *