'Rebase to remove unwanted commits from a branch

I have a branch master that I branched off of and I want to merge my changes into a release branch. The thing is tho, since I branched off of master I have commits in my branch that don't need to go into the release branch. I tried rebasing like git rebase origin/release but that doesn't seem to remove the unwanted commits. How can I remove the unwanted commits and have my work on top of the release work?



Solution 1:[1]

The problem is you're giving the wrong rebase command. Say

git switch mybranch
git rebase --onto release master mybranch

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 matt