Learning center

Take over a pull request when its author is gone

Fetch the pull request's commits from the base repository. Then check whether you can push to its branch, and choose between continuing there and opening a new pull request. The commits stay reachable through refs/pull/NUMBER/head even when you cannot write to the author's fork.

Get the commits#

git fetch origin pull/1423/head:takeover/1423
git log --format='%h %an %ad %s' --date=short origin/main..takeover/1423

This needs no access to the fork. GitHub's documentation describes it for authors who are unresponsive or have deleted their fork. Checking out pull requests locally

You can see the ref on any public pull request: git ls-remote https://github.com/octocat/Hello-World 'refs/pull/1/*' prints a head and, for that one, a merge ref.

Continue or replace#

SituationChoice
The branch is in your repositoryContinue on it, after telling the author
A fork on a personal account, and the author allowed maintainer editsYou can push to it, if you have push access to the base repository
A fork without that permission, or a fork that was deletedOpen a new pull request from your branch
A fork owned by an organizationCheck the pull request's sidebar before you plan on pushing. The documented permission covers forks in personal accounts
The review thread is long and mostly settledPrefer continuing, since the threads stay attached
The approach is changingOpen a new one and link both

Allowing changes to a pull request branch states who can commit to the branch.

Read the state before you write#

  1. The base. git merge-base origin/main takeover/1423 tells you how old the branch's view of the code is.
  2. Reviews, with the commit each one read. An approval of an older head is history.
  3. Unresolved threads, and resolved ones where no commit followed. A thread may have been closed by an explanation you need.
  4. Checks on the current head, and whether they still exist. A renamed check can leave an old result with no equivalent.
  5. The author's unpushed work. Ask, because you cannot see it. Their last push may be a week behind their laptop.

Run the tests on the branch as it is before you merge the base in. If they fail now, the failure came with the branch. If they pass now and fail after the merge, the interaction did it. Once you have merged first, you can no longer tell.

Keep authorship#

Keep the author's commits when you can. If you must squash or rewrite, add a trailer with the address they used in their commits:

Co-authored-by: Ana Example <ana@example.com>

Check the project's contribution terms when the author has not agreed to them, since a takeover does not change who wrote the code.

Worked example#

This example is fictional. Ben takes over a change that has been idle for six weeks. Tests pass on the branch, and fail once main is merged in: a helper's signature changed. Of three resolved threads, one was closed with "will do in the next push", and no push followed. That thread holds the real remaining work. The fork does not allow edits, so he opens a new pull request with Ana's commits, his merge and that fix, links the old one and closes it.

Split out what earlier reviewers covered before asking for a new review. Return to handing over evidence.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading