Force GitHub Pull Requests to update the diff against its target branch

Updated . Posted . Visible to the public.

When you have a Pull Request on GitHub that includes commits from another Pull Request, you will still see them after the "child" PR has been merged. Unfortunately, GitHub won't automatically update the diff (or commit list).

Here is what worked for me:

  1. Check out the target branch
    1. git checkout my-target-branch
    2. Make sure you are up to date against origin (e.g. git fetch and git status). You should be 0 commits ahead or behind.
  2. Add and commit a file
    1. touch .please-update
    2. git add .please-update
    3. git commit -m "Force PR update"
  3. Push
  4. Do a hard reset to the state before adding above file:
    ^
    git reset --hard HEAD~
  5. Push that state again to production with a forced push:
    ^
    git push --force origin my-target-branch

That will make GitHub update the diffs on all Pull Requests going to that branch.

Important: While this works nicely for integration branches, you probably do not want to do this for master or other high-traffic branches.
In that case, you can do the above for your source branch (the one that's being merged into master). Obviously, only the PR of that branch will be updated, but may just be enough.

This feels clumsy, but it seems there is no way to make GitHub do this nicely. :( If you know of a better approach, please let me know.

Arne Hartherz
Last edit
Arne Hartherz
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2012-12-12 09:50)