Undo event based push git version control

Summary

  A few years ago Internet projects we also use more than do svn version management, with the continuous optimization git, as well as the evolution of the Internet architecture model, git increasingly favored by developers.
  Bloggers experienced several projects are also used as the git version control project. Now most of the works after initialization, in addition to the master points, the branch will increase the dev and test, in order to facilitate the management of the development code (Some projects will establish more branches to manage). In general, we ask only allows developers to code commit and push operations dev branch. Of course, sometimes you can not avoid a fear of death error in test or other non-dev branch push code. Bloggers just before the company experienced such a thing, when we opened the branch of the project more than (do not ask me why so many open branches Party uncle requirements), on several occasions after the code was mistakenly pushed out new colleagues mess. This article, we have to solve this problem.

Withdrawal step (assuming mistakenly pushed in the test code branch)

1-> git log

Check to submit their records to find the last version number

2-> git reset --soft <version number>

Parameters soft means: keep the current work area, you can also choose to resubmit parameters hard, you revoke modify the corresponding work area, be sure to use caution

3-> git push origin master –f

After rollback, the code before submitting a strong push to the remote branch

4-> get

Guess you like

Origin blog.csdn.net/qrainly/article/details/94991669