Read more

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

Arne Hartherz
December 12, 2012Software engineer at makandra GmbH

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).

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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.

Posted by Arne Hartherz to makandra dev (2012-12-12 10:50)