How does Git cancel commit, how do You cancel the commit after Git commit, and how do you change the commit content
When you’re using Git, you might accidentally click commit, so how do you plug in the commit?
1. You can first check the historical commit record with Git Reflog
Soft, soft
The local code does not change, except that git transitions revert to the pre-COMMIT state
Do not delete the workspace change code, undo commit, and do not undo Git Add.
git reset --soft HEAD~1
Represents the last commit to be revoked, and 1 can be replaced with an earlier number
Hard to cancel
The native code will change directly to the specified commit version. Use with caution
Delete the workspace change code, undo commit, undo Git Add.
Note that after this operation, the last COMMIT state is restored.
git reset --hard HEAD~1
If the message content is just COMMIT, the error is filled in
The input
git commit --amend
Enter ViM mode and make changes to Message
There’s another one, mixed
git reset --mixed HEAD~1
Do not delete the workspace change code, undo commit, and undo git Add. Operation
is the default parameter,git reset –mixed HEAD~1 and git reset HEAD~1 have the same effect.