Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 781
Kriem Avatar asked Apr 25 '13 09:04

Kriem


People also ask

How do I go back to a previous version of Git?

Returning to an Old Revision. The fastest way to restore an old version is to use the "reset" command: $ git reset --hard 0ad5a7a6. This will rewind your HEAD branch to the specified version. All commits that came after this version are effectively undone; your project is exactly as it was at that point in time.

What is the difference between GIT revert and reset?

The net effect of the git revert command is similar to reset, but its approach is different. Where the reset command moves the branch pointer back in the chain (typically) to "undo" changes, the revert command adds a new commit at the end of the chain to "cancel" changes. The effect is most easily seen by looking at Figure 1 again.

How do I revert a commit in Git?

Committing little and often, so that your change history is clear should save you from having to take this route. Whichever option you use, take a note of the ID of the commit you want to revert to. Use git checkout & the ID (in the same way you would checkout a branch) to go back: $ git checkout <commit-id> .

Why use Git for version control?

Using a version control system like Git brings a fantastic benefit: you can return to any old version of your project at any time. No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!


1 Answers

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
like image 138
1615903 Avatar answered Oct 27 '22 09:10

1615903