Adding Commits to Someone Else's Pull Request

Feature image: Adding Commits to Someone Else's Pull Request

At Tighten, we do lots of open source work. We even have a whole day every week devoted to it. And, thankfully, we have many members of the open source community contributing pull requests to our projects and packages.

But occasionally we have a pull request that needs one tiny fix: an updated Travis config file, a small adjustment to the composer.json version constraints, or a typo in the readme. We could review the pull request and ask for those changes, and that's often our strategy on internal projects.

Isn't there an easier way? Can't you just add your own commits to someone else's pull request?

Yes. And it's very easy.

example git branches showing this process

How to add commits to someone else's pull request

In our example, you are Ford Prefect. You're working on the latest edition of the Hitchhiker's Guide to the Galaxy in the repo fordprefect/the-guide. A wonderful open source contributor Arthur (arthurdent) forks your repo and makes a pull request.

Arthur's pull request looks great, but he misspelled "towel" in one section as "tolwe." Open source contributors are great, but what if he doesn't ever come back to this pull request? Instead of asking him to fix it, you want to quickly push a fix yourself.

Step 1: Clone

If you haven't already, clone your own repo locally.

git clone

Step 2: Add a remote

In order to see the other user’s fork (and push commits to it), you'll add their fork as a remote to your local repo.

git remote add arthurdent

You should now see the fork as a new remote, called arthurdent, when you run git remote -v:

sites/git/the-guide on main git remote -v
origin (fetch)
origin (push)
arthurdent (fetch)
arthurdent (push)

Step 3: Fetch from this new remote

git fetch arthurdent

Step 4: Check out their branch locally

You'll need to check out the branch they used for the pull request. If you're not sure what branch they used, look on the top of the pull request (e.g., arthurdent:main). Name it something other than main locally so there's no conflict with your own main branch.

git checkout -b arthurdent-main arthurdent/main

Step 5: Commit and push

Make your changes locally, commit, then push to their remote’s head.

git commit -am "Fix how you spelt towel"
git push arthurdent HEAD:main

That's it! If all goes well, you'll see this commit show up at the bottom of the pull request.

example pull request showing new commit

Potential Issues

! [remote rejected] HEAD -> main (permission denied)
error: failed to push some refs to ''

If you get an error when pushing, the other user might have unchecked the box in the pull request that says “Allow edits from maintainers.” Have them check that box in the pull request view and try again.

Get our latest insights in your inbox:

By submitting this form, you acknowledge our Privacy Notice.

Hey, let’s talk.

By submitting this form, you acknowledge our Privacy Notice.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Thank you!

We appreciate your interest. We will get right back to you.