This article will take you to understand the difference between git reset and revert

No obscure definitions! Summarize yourself and directly distinguish.

1. reset is to completely roll back to the specified commit version, and all commits after the commit will be cleared; while revert only cancels the modification of the specified commit, and does not affect subsequent commits.


2. No records will be generated after reset is executed, but records will be generated after revert is executed.

To give a common practical chestnut in development:

For example, if the abc version submitted in chronological order is reset to a, then the changes in bc will be changed.
But reverting to a will only change a, but bc will not change, so revert will not cause changes in historical submissions.

Have you learned it? Let's do some exercises

Cancel the submission with commitId a1234 in the version library, and it cannot cause changes to the historical submission, what operation to use (C)
A, git reset --hard a1234
B, git rebase -i a1234
C, git revert a1234
D, git checkout a1234

Look at the bold red font, that's why you choose C for this question

Guess you like

Origin blog.csdn.net/m0_71981318/article/details/127806881