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#
| Situation | Choice |
|---|---|
| The branch is in your repository | Continue on it, after telling the author |
| A fork on a personal account, and the author allowed maintainer edits | You can push to it, if you have push access to the base repository |
| A fork without that permission, or a fork that was deleted | Open a new pull request from your branch |
| A fork owned by an organization | Check 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 settled | Prefer continuing, since the threads stay attached |
| The approach is changing | Open 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#
- The base.
git merge-base origin/main takeover/1423tells you how old the branch's view of the code is. - Reviews, with the commit each one read. An approval of an older head is history.
- Unresolved threads, and resolved ones where no commit followed. A thread may have been closed by an explanation you need.
- Checks on the current head, and whether they still exist. A renamed check can leave an old result with no equivalent.
- 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.