At my work we use something resembling gitflow. We had a release branch with several features already merged, and I needed to add a feature to that release that depended on those features, therefore I branched off release and made a bunch of commits.
Over that period, that release branch was dropped. The features that were intended for that release were merged into master separately, and others were dropped. Therefore that release branch is obsolete.
I now have a situation where my feature branch has a load of commits that I really want to merge with master. The obvious way is to fork a new branch off master and then cherry pick the commits over and then merge straight away.
However, the question I'd really like to have answered is whether it's possible to basically manipulate my existing branch to emulate the effect of having it match master and then keeping my recent commits on top. The reason being that the PR already exists, there are already various workflows for a staging host that is running off changes to my existing branch etc.
An interactive rebase looks too complicated because it'll require combing through a lot of commits. A rebase --onto looked promising, but unless I've misunderstood, that also creates a new branch. Alternatively, if I do the branch+cherry-pick on a temporary branch, can I then delete my old feature branch and rename the new one before force pushing back to origin?
You have indeed misunderstood what a rebase is. If your branch is
mybranch, then you would sayThis would keep
mybranchbut it would rip the "start" of it (the "first" commit ofmybranchproper) off its previous parent and glue it onto the end ofmaster.Be fearless, because if you do this and you think you've made a mistake, your action is 100% undoable thanks to the
reflog.