Alex
Alex

Reputation: 1349

Git rollback-branch then merge

I have made several commits to the MASTER (say A, B and C, where C is the latest). Then due to strange bug I have made a branch FIX from commit A and added commits D, E and F to the branch fix.

So now I have MASTER with A-B-C and FIX with A-D-E-F and I need to merge it all to MASTER removing commits B and C, so final MASTER should contain A-D-E-F. How can I achieve that?

Upvotes: 0

Views: 53

Answers (1)

Yaron
Yaron

Reputation: 620

Quick Answer - to reset to A (if C is latest commit) run:

$ git reset --hard HEAD~2

Then you're free and clear to run

$ git merge <branch_name>

it will be as though B and C never existed.

Suggested read - a more in depth answer in regards to using reset in git: https://stackoverflow.com/a/6866485/2491655

Upvotes: 1

Related Questions