Using git flow, how would I revert back to a previous release?

Kriem picture Kriem · Apr 25, 2013 · Viewed 8.8k times · Source

I'm using git flow for my projects. When a release has been merged into the master branch it is tagged with the release version (e.g. 1.2.0) and deployed to my production servers.

Now I want to quickly revert to the previous release tag (e.g. 1.1.0) as the deployment should not have happened.

Elaboration:

  • I merge the 1.2.0 release branch into the master branch.
  • I tag the master branch with 1.2.0.
  • I push my local repo to the origin.
  • I conclude that I released too early.
  • I want to revert back to the state of master where it was tagged as 1.1.0.
  • I want the master @ origin to revert back to the 1.1.0 state as well.

enter image description here

How would I do this?

Answer

1615903 picture 1615903 · Apr 25, 2013

Assuming you want to keep the history, but undo the changes the 1.2.0 release did. Use git-revert to create a new commit that reverts everything 1.2.0 did:

git checkout master
git revert HEAD