Home > Enterprise >  Merging a rebased branch into the un-rebased version of it
Merging a rebased branch into the un-rebased version of it

Time:07-01

I have a branch FEATURE that was split from MAIN about a year ago, and has some extra features.

I have created a new branch MY-FEATURE from the FEATURE branch.

I have rebased MY-FEATURE branch to the latest MAIN branch, and I discarded a commit, where MAIN was merged into FEATURE about 6 months ago.

What's the best way to now make the remote FEATURE Branch same as the MY-FEATURE branch?

Would merging MY-FEATURE into FEATURE do the trick? It feels like I may start getting into a world of pain, especially since I discarded a merge commit during the rebase.

CodePudding user response:

If you just want the FEATURE branch to point to the MY-FEATURE branch, you may simply hard reset the former to the latter:

# from FEATURE
git reset --hard MY-FEATURE
# force push, if you like
git push --force FEATURE

Note that a force push of FEATURE to the remote would be necessary here, as its history has been rewritten. You should probably avoid doing this if FEATURE be in use by other people.

  • Related