Skip to content

retargeting

How to change a pull request’s base branch, and what it does to the diff and reviews

Othman Shareef · November 22, 2026 · 5 min read


To change the base branch of a pull request on GitHub, open the pull request, click Edit title next to the title, pick the new branch in the base branch drop-down, and confirm with Change base. From the terminal it’s gh pr edit 123 --base main, and through the REST API it’s a PATCH to the pull request with a new base. The pull request keeps its number, comments and reviews, but the diff is recomputed against the new branch, so some commits can drop out of the timeline and some review comments can go outdated.

Changing the base branch in the GitHub UI

From GitHub’s docs on changing the base branch:

  1. Open the repository’s Pull requests tab and click the pull request.
  2. Next to the pull request title, click Edit title (the pencil).
  3. In the base branch drop-down menu, pick the branch you want to compare against.
  4. Read the note about changing the base branch and click Change base.

The same dialog edits the title, so you can fix both at once. If the drop-down doesn’t show the branch you want, check that it exists in this repository: a branch in a fork or in the upstream repository can’t be a base for this pull request.

From the terminal with gh pr edit

gh pr edit takes -B or --base, described as “Change the base branch for this pull request”:

gh pr edit 123 --base main
gh pr edit --base release-2.4   # the pull request for the current branch

Without a number, URL or branch, gh edits the pull request for the branch you’re on. When I have to move more than one pull request, say every open one against a release branch after the release is cut, I script this instead of clicking through the UI.

Through the REST API

Use Update a pull request, PATCH /repos/{owner}/{repo}/pulls/{pull_number}, with base set to the name of the branch you want the changes pulled into:

gh api -X PATCH repos/OWNER/REPO/pulls/123 -f base=main

The docs say the base should be an existing branch in the current repository, and that you can’t point it at another repository.

What retargeting does to the diff

A pull request shows a three-dot diff: everything on the head branch since its merge base with the base branch. Pick a new base and you get a new merge base, so the diff, the commit list and the files changed count can all move. Commits the new base already contains drop out, which is why GitHub warns that some commits may be removed from the timeline.

Review comments stay on the pull request, but a comment whose line is no longer part of the changes goes outdated. Reviewers who already read the old version are better off looking at only what changed since their review than starting over. If the new base has moved ahead of your branch, you’ll also see the usual out-of-date branch prompt.

Does changing the base branch dismiss approvals?

GitHub’s protected branch docs don’t mention base changes by name. They do say that with stale approval dismissal on, approving reviews are dismissed if the merge base introduces new changes after the review was submitted, and a new base usually brings a new merge base with changes in it. The new base can also have its own protection rules, so a pull request that was ready to merge into one branch may be blocked against another.

Retargeting a stack after the parent merges

In a hand-built stack, the child pull request targets the parent’s branch. When the parent merges and someone deletes its head branch, or the Automatically delete head branches setting does, GitHub changes the base of open pull requests that targeted the deleted branch to the merged pull request’s base. If the branch stays around, retarget the child yourself with any of the methods above. With GitHub’s native stacked pull requests, the PRs above a merged layer are rebased and retargeted for you.

If the parent was squash merged, the child branch still holds the parent’s original commits and main only holds the squash commit, so after the retarget the child’s diff can show the parent’s changes all over again, which is confusing as hell for whoever reviews it next. Rebase the child onto main and drop the parent’s commits (git rebase --onto main parent-branch child-branch), then force-push. Our merge method comparison covers why squash does this.

Frequently asked questions

Can I change a pull request’s base branch to a branch in another repository?

No. The REST API docs say you cannot update the base branch of a pull request to point to another repository, and the base has to be an existing branch in the current repository. To target a fork or the upstream repository, open a new pull request there.

Does changing the base branch dismiss approvals?

GitHub’s docs don’t say it directly. If the branch has Dismiss stale pull request approvals when commits are pushed turned on, approvals are dismissed when the merge base brings in new changes after the review, and a new base usually means a new merge base. Expect to ask for approval again.

Why did my stacked pull request retarget to main on its own?

When a merged pull request’s head branch is deleted, GitHub finds open pull requests in the same repository that use that branch as their base and changes their base to the merged pull request’s base. With native stacked pull requests, the PRs above a merged layer are retargeted automatically too.

Review your next PR in Pyor.

Pyor’s merge box updates the branch, merges with any method the repo allows, turns on auto-merge, or joins the merge queue, in the same window you review in. Free for individuals, and it talks to GitHub straight from your machine.