Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding commits to another person's pull request on GitHub

My project on GitHub has received a pull request. The pull request only partly fixes the issue that it's addressing. I've pulled in the changes to a local branch and added some commits of my own.

I'd now like to push those commits back to my remote repo and have them show up on the pull request, but without merging them into the target branch. I'd like to keep the pull request open for further review and discussion, and potentially further commits.

Is there a way I can add commits to the pull request without merging them into the target branch and therefore closing the pull request?

like image 886
John Blackbourn Avatar asked Jan 05 '14 00:01

John Blackbourn


People also ask

Can I update someone else's pull request?

You cannot add commits directly to User B's pull-request unless you have write access to User B's fork. You can, however, make local additions to the pull-request, by just fetching the pull-request branch into your own local repo (assuming the url for B's fork is public).

Can you push to someone else's PR?

To push changes/commits back to someone else's PR in an upstream project. In the command, someoneelse is where you put the name of the user's account that the PR is from.


3 Answers

As long as the original author has clicked the checkbox in the bottom right:

Allow Maintainers

If that box is checked, then you can push back to the original branch without needing to add a remote by using:

git push [email protected]:user/repo local_branch_name:remote_branch_name 

This is particularly useful if you're using a tool like hub where you can check out a pull request without needing to add a remote.

Edit: You also need to have write access to the repository where the PR has been opened.

Further Edit: The new command line tool from GitHub does a good job of checking out PRs so that you can just use git push as is to push updates to remotes (assuming you have permission).

like image 162
Wesley Bland Avatar answered Oct 09 '22 06:10

Wesley Bland


It is possible to do this now (link)

Suppose you have received a pull request in yourrepo from otheruser.

Add the other user as a remote

git remote add otheruser https://github.com/otheruser/yourrepo.git 

Fetch

git fetch otheruser 

Create a branch from their repo

git checkout -b otheruser-master otheruser/master  

Now make some changes and commit. Push to their repo

git push otheruser HEAD:master 
like image 44
Mendhak Avatar answered Oct 09 '22 06:10

Mendhak


Not unless barryceelen gives you push access to his fork. You'll have to close his pull request and open a new one from your branch that includes his commits.

Not being able to do what you want to do is annoying. To make better use of GitHub flow, I'd suggest asking forkers to open issues separately from their pull requests that solve them, meaning you can keep the initial conversation flow and have it closed by whatever pull request you decide as the best.

like image 34
Henry Blyth Avatar answered Oct 09 '22 06:10

Henry Blyth