Search code examples
gitgit-branchrebase

Need to drop multiple commits from pull request


I accidentally created git branch B, while being on branch A. Then i created a pull request, where i saw, that all the commits from branch A were transfered on B branch. I need to delete all A commits from B branch \ pull request without closing a pull request.


Solution

  • Just rebase B onto the correct starting point (ie, not A), and then push it again (with --force if necessary).

    The first step is a git rebase --onto X A B (where X is whatever starting point B should have), exactly as covered in the manual.

    The second step is just repeating whatever git push you already used.