Remember once the GIt remote master branch is covered by the old code branch and cannot be rolled back, and then restore the solution

本方法需要一个最近提交过的正常分支。

Solution:

  1. Check out a branch that was recently committed (code that needs to be restored) locally, and then checkout to this branch.
  2. Compress the required code into a compressed package (in order to replace the code covered by the old code).
  3. Then go back to the branch where the problem occurred locally
  4. Unzip the compressed package and replace the code on the problem branch covered by the old code.
  5. The remote branch creates a new branch, such as the name: recover_old
  6. Push the code of the local problem branch to the newly created recover_old branch
  7. Finally, recover_old is merged into the remote master branch. ,that's it

Why create a new recover_old branch?
Because after the branch is merged, if it is wrong, it can be restored to before the merge.

Guess you like

Origin blog.csdn.net/qq_39004843/article/details/106563580
Recommended