1. The deploy branch is the branch of the production environment, and master is the main development branch.
2. The deploy branch has several file configurations that are different from those of the master branch. Usually, the master branch is merged into the deploy branch, which does not change the configuration file information under the deploy branch.
3. Accidentally merged the deploy branch into the master branch, causing the configuration file under the master branch to be changed to that under the deploy branch, and a push was made, and the configuration file under the remote master branch also became under the deploy branch. .
4. Changed the configuration file under the master branch and re-push it, but now I dare not merge it into the deploy branch because I am worried that the configuration under the master branch will replace the configuration under the deploy branch.
Now I want to restore the version before the master branch and the version in the remote warehouse. What to do?
In fact, this is very easy. The author can perform the rollback operation locally first:
Retrieve the hash value corresponding to the previous master status through the submission log
Copy its hash value, if it is 664d6cf35a7.
Then time travel and return to the previous state
After rolling back, delete the remote master branch:
If you cannot delete it, you can first set the default branch to another branch remotely, such as deploy. If the poster's remote warehouse is on github, you can click on the setting->branches-.default branches of the corresponding warehouse and modify it.
Then run the above command to delete the remote master branch.
After deletion, you can now push the master branch again, which will re-establish a master branch in the remote warehouse. After pushing, change the remote default warehouse to master again.
The current situation is basically the same as before.
Roll back the local branch > Delete the remote branch > Push the local branch (that is, create a new remote branch)
However, this method is not suitable for protected branches such as master. You can use the following method:
Rewind local branch > Force push local branch (force push to overwrite remote branch content)