Peter Warbo
Peter Warbo

Reputation: 11728

Git-Flow undo a finished feature branch

What options do you have if you want to "undo" a feature branch? Let's say you add a new feature supercool-feature which you finish (merge into development and delete the feature branch) and then it goes into a release. But then your users really dislike this supercool-feature. How can I undo/rewind/reverse this feature which has been already merged into development and a release?

I'm using SourceTree to do my versioning.

Upvotes: 6

Views: 7037

Answers (2)

Nils Werner
Nils Werner

Reputation: 36835

Run this command

git revert -m 1 <sha1 of M>

Explanation

Your situation is about as follows:

A-B-----C---D-M     # master
   \         /
    X-Y---Z-        # supercool-feature

A, B, C and D were in your master branch, X, Y and Z in your feature branch. When you did git merge supercool-feature Git created a "merge commit" M for you. This commit encloses all commits from your feature branch as well as possible fixes to fix merge conflicts. So if you revert that one commit, every change from your featurebranch will be gone again.

Upvotes: 16

user3041461
user3041461

Reputation: 9

Actually the command is

git revert -m 1 <sha1 of M>

which remove M moving back on branch containing X,Y,Z which is not the mainline 1.

Upvotes: 0

Related Questions