Technology

Making changes to a GitHub PR branch on a fork

A while back, GitHub added a setting for contributors to allow maintainers of a repo to push changes to a pull request branch of their fork. I've been doing a lot more work in GitHub recently and figured I'd document my Git process for handling pull requests where you just want to close up a couple small things in a given time frame and/or the originator isn't very responsive. IMO this makes it much easier to retain the commit history giving credit to the other person but still move existing PRs forward.

The essence of my process is to add their fork as a remote, switch to that branch, do stuff and commit, and then push to it. It's not really a whole lot, but I've found that very specific snippets come in very handy, even if they're short and straight-forward. I also don't like the instructions GitHub gives for making changes to a fork's branch. So, that gives us (using a real recent example):

If you use hub (I don't), I believe you can skip the first command as fetch will add the remote for you if it's not recognized. There's also the popular Git Extras, which has a pr command, but from what I've tested it doesn't use the actual remote branch the PR originates from even if you specify the remote, but rather the pulls/### branch GitHub makes for you. If you use (or decide to write) a Git helper that does the remote adding/fetching/checkout for you (e.g. git pr KZeni/patch-1 or even making it so that git pr ### could detect the remote fork and branch for that PR), let me know!

Standard

3 thoughts on “Making changes to a GitHub PR branch on a fork

    • helen says:

      Neither! The fork owner can choose a setting to allow edits from maintainers (push access, I think?) of the original repo to the branch they’re using for a PR. It’s a setting in the PR itself and I’m not sure if it defaults to on or off, but it’s a pretty cool setting and eases my mind a lot about about abandoned-but-decent PRs.

Leave a Reply