How to undo after git commit

        After modifying the local code, when submitting the changed code to the remote library, you may encounter a situation where the comment is wrongly written, so how to withdraw the wrong commit operation and re-commit at this time.

Case 1 : Undo git commit command and undo git add

Command: git reset --hard HEAD^

Function: Delete the modified code in the workspace, undo commit & undo add

Case 2 : Only revoke the git commit command

Command: git reset --soft HEAD^

Function: Do not delete the modified code in the workspace, only undo the commit

Guess you like

Origin blog.csdn.net/Stitch_xiao/article/details/128789653