Search code examples
gitrebase

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

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

    git switch mybranch
    git rebase --onto release master mybranch