How to return master branch to tag in git?

We have the origin and development of branches. The initial state of the wizard was marked as tag_ABC .

We have few changes made to the development industry and transferred to the initial state. Then we accidentally merged, developing into a master and pushing towards the origin.

Now we would like to return the tag_ABC to the master point. How can we do this?

+53
git
Jul 29. '11 at 11:10
source share
2 answers

You can do

 git checkout master git reset --hard tag_ABC git push --force origin master 

Please note that this will overwrite the existing story in the upstream repo and may cause problems for other developers who have this repo.

+109
Jul 29 '11 at 11:31
source share
— -

This is not a direct answer to the question, but this page returns when looking for ways to return the branch code to the tag release.

Another way is to create the difference between the current state of the branch and the tag that you want to return to, and then apply it to the branch. This keeps the version history correct and shows what changes are happening and then returns again.

Assuming your branch is called master , and the tag you want to return to is called 1.1.1

 git checkout 1.1.1 git diff master > ~/diff.patch git checkout master cat ~/diff.patch | git apply git commit -am 'Rolled back to version 1.1.1' git push origin master 
+21
Nov 24 '15 at 9:38
source share



All Articles