I need to untangle a feature branch from an underlying develop branch. We have two immortal git branches: An upstream development branch and stable branch that gets deployed. Our workflow calls for feature branches is to merge to develop, go through a manual test process there and merge the feature branch to when it passes the test. That way the product team knows where they can test and we can catch feature interactions.
Unfortunately, I started a feature branch by merging it from develop instead of from stable, and later merged it into my feature branch again. So even though my feature got merged to develop, got through testing and should be going to stable, I can't merge it to it, since it contains code from other feature branches that got merged to develop, but haven't gotten through testing yet.
So I basically need to remove all the unrelated commits from my feature branch or get all good commits to another one.
A coworker figured we could copy paste the related files. That should work, since it's a fairly isolated feature, but I'd like to have the same commits on the feature branch, on develop and on stable, so we don't get weird merges and even more commits polluting our history.
I initially tried branching a new branch from stable, getting all related commits in reverse order via git log and cherry-picking them over. But that got me merge conflicts and problems from merge commits for some reason.
Then I tried branching a new branch from stable, rebasing it against the feature branch and dropping all unrelated commits. That worked, but git sees a lot of differences between the new feature branch and both the old feature branch and develop (where it got merged into) for some reason.