Dr.Gonzo
Dr.Gonzo

Reputation: 107

Undo a git flow feature finish which merged a feature into development

I have accidentally just merged a feature branch into a master branch.

I ran git flow feature finish and forgot to put in the name of the feature branch. How can I undo this change.?

After doing this I got the following error:

- [deleted]           feature/hidden_campaign
Deleted branch feature/hidden_campaign (was ab77e680).

Summary of actions:
- The feature branch 'feature/hidden_campaign' was merged into 'master'
- Feature branch 'feature/hidden_campaign' has been locally deleted; it has been remotely deleted from 'origin'
- You are now on branch 'master'

Any help would be really great

Upvotes: 2

Views: 691

Answers (1)

Josh Stevens
Josh Stevens

Reputation: 4221

ok so you need to do 2 things.. firstly you want to un-delete that branch as you need it back

git checkout -b feature/hidden_campaign ab77e680

This is creating a new branch but using your sha defined in your deleted output to get it back to how it was before.

Then checkout back to your master branch, i am assuming this was the last thing you pushed into master so you can do.

git reset --hard HEAD^

HEAD^ means the first parent of the tip of the current branch.

git commits can have more than one parent. HEAD^ is short for HEAD^1, and you can also address HEAD^2 and so on as appropriate.

This will put your branch back to how it was before the merge and you have your feature/hidden_campaign branch back

Upvotes: 4

Related Questions