Pushing to someone else's pull request on GitHub

If you’re a maintainer of an open source repository on GitHub, you often want to make a small change to a pull request but don’t want to wait for the original author to make changes or open a brand new pull request. GitHub now allows upstream maintainers, with permission, to push to downstream forks, but the provided instructions don’t meet my needs. Specifically, I don’t want to have to re-clone an entire repository for every contributor, and I don’t want to pollute my local repository with a bunch of remotes pointing to contributors’ forks.

It took a little while to figure out some problems with credentials, but basically you can just push directly to SSH URLs, assuming you have your SSH keys set up properly.

  1. Open Terminal and install hub if you haven’t already, then navigate to your git repository. If this is your first time using hub you might be prompted for your GitHub credentials.

    brew install hub
    cd my-git-repo
    
  2. Fetch the changes from the downstream fork, add a tracking branch, and switch to that branch:

    hub fetch [email protected]:CONTRIBUTOR_NAME/REPOSITORY REMOTE_BRANCH:LOCAL_BRANCH
    hub checkout LOCAL_BRANCH
    
  3. Make changes as necessary and commit them.

  4. Push your changes to the downstream fork:

    hub push [email protected]:CONTRIBUTOR_NAME/REPOSITORY REMOTE_BRANCH
    

You should now see the changes reflected in the pull request online!