Step 1: View commit history
git log
This will list your commit history, including the commit hash, author, date, and commit message.
Exit the log: Press Q on your keyboard.
Step 2: Use git revert
fallback code
Find the version number you need to roll back, which is the commit hash:
git revert <commit-hash>
Example:
Just press Enter.
Step 3: After pressing Enter, you will enter the Vim editor
Don't panic at this time.
①Press the ` i ` key to enter insert mode.
② Then roll your mouse wheel to the ` # ` number at the bottom and enter the information you want to roll back.
Clearly state why you want to revert this commit.
③ Press Esc
to exit insert mode.
At this time, the following insertion will no longer exist.
④ Enter :wq
and press Enter
to save and exit the Vim editor.
After confirming that you have entered the information, enter :wq to exit and it will be saved automatically.
⑤After pressing Enter, you can see that the rollback has been successful. At this time, the code rollback status belongs to the commit status;
git push is required.
Step 4: To verify the code, you can go to the warehouse to have a look.
As a result, records like this are rolled back. It means success.