How does IDEA roll back Git to a certain version

Most of the online information is "reset current branch to here", select the hard mode, and then force the push method. Although both the local and remote repositories can be restored to a certain commit, no commit record will be generated. As a result, when other people who jointly develop on this branch commit next time, they will resubmit the code you have rolled back. Your return Failed to retreat.

Later, according to the steps in this article, the test is effective, because a submission record can be generated, so that when others synchronize the code, your latest submission record will be synchronized.

1. Check the Git history through IDEA and copy the current version number.

Git->Show History->Copy Revision Number

2. After recording the current version number, copy the version number you want to roll back

Git->Show History->Copy Revision Number

3. At this point we have two version numbers, one is the current version number, and the other is the version number to be rolled back. Click Rest HEAD, select Hard (emphasis) for Rest Type, and enter the version number to be rolled back in To Commt

Git->Reset Head->Rest Type select Hard (emphasis), enter the version number to be rolled back in To Commt->Reset

4. At this time, we have returned to the previous version, but do not rush to push the code at this time. We click Rest HEAD again, and select Mixed for Rest Type, fill in the current version number just copied for To commit, and then click Reset. (Remember, the version number filled here is the one we copied in the first step)

Git->Reset Head->Rest Type select Mixed, enter the current version number in To Commt->Reset

5. At this point, you only need to submit the code, a submission record is generated, and the rollback is completed.

Original link: https://blog.csdn.net/earthhour/article/details/124376883

Guess you like

Origin blog.csdn.net/weixin_49934658/article/details/130349328