Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git-Flow undo a finished feature branch

Tags:

git

git-flow

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.

like image 265
Peter Warbo Avatar asked May 28 '13 12:05

Peter Warbo


People also ask

What does git flow feature finish do?

So in our case, when we "finish" a git flow branch, it makes sense to immediately push the branches + tags to the remote instead of having to enter the git flow commands directly. After entering this config, git flow will automatically push the branches on the remote, thus saving extra time and avoiding confusion.


1 Answers

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.

like image 186
Nils Werner Avatar answered Sep 20 '22 02:09

Nils Werner