7

I own a repository and someone has submitted a pull request. I want to make some changes to that pull request before bringing it in, is this possible to do?

Note, I'm expecting for my commits to show up in the pull request thread so that the conversation can continuem, etc.

I know that I could go off and clone his fork, and pull in my branch once I have finished but that doen't really fit with the workflow around discussion and improvement.

vdh_ant
  • 12,720
  • 13
  • 66
  • 86

3 Answers3

12

GitHub has added an ability to allow users with write permissions to the branch against which the PR is being raised to have write rights to the originating branch.

This is an opt-out feature, i.e.

Only pull request creators can give upstream repository maintainers, or those with push access to the upstream repository, permission to make commits to their pull request's compare branch.

[..]

Pull request creators can give these permissions on each of their pull requests when they initially create a pull request from a fork or after they have created the pull request.

https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/

Example

Lets use this PR as an example, https://github.com/gajus/table/pull/19.

User epoberezkin created a pull request against gajus:master. The origin of this request is epoberezkin:precompile-schemas. Therefore, as a user with write-permissions to gajus:master I can push to epoberezkin:precompile-schemas branch and these changes will be reflected in the PR, i.e.

git clone git@github.com:gajus/table.git
cd table
git remote add epoberezkin git@github.com:epoberezkin/table.git
git fetch epoberezkin
git checkout epoberezkin/precompile-schemas
# Make changes, commit changes.
git push epoberezkin HEAD:precompile-schemas
Gajus
  • 69,002
  • 70
  • 275
  • 438
6

If there's an open pull request on a repository that you own, only if you commit to the repository and branch (their repository and their branch) that has the open pull request will that work.

So.. you need to create a pull request to the forker's repo if you want to achieve literally what you've requested - that your commits appear in their pull request

AD7six
  • 63,116
  • 12
  • 91
  • 123
  • Ok so to get this to work I would submit a pull request to his fork and once he accepts it, the commit would show up in the original PR? – vdh_ant Mar 03 '13 at 22:00
  • it's clumsy but yes, that'd work. you need to make sure your commits go to the same branch as the open PR. – AD7six Mar 03 '13 at 22:01
  • Without doing a full clone of the forked repo, is there a way to switch branch to that fork? – vdh_ant Mar 03 '13 at 22:04
  • 1
    It's almost the same steps as [merging a PR manually](https://help.github.com/articles/merging-a-pull-request). e.g. add a remote for their repo, fetch from it, create a branch, `git reset --hard their branch-name` and you then have a branch on the same commit as the branch in their repo. – AD7six Mar 03 '13 at 22:11
1

You just need to

  1. download the branch
  2. make changes
  3. commit them
  4. push them

After pushing the changes you will see them in the Github pull request and the workflow will be respected.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
iberbeu
  • 15,295
  • 5
  • 27
  • 48
  • 3
    Isn't 5. the person who owns the pull request needs to accept it? – vdh_ant Mar 03 '13 at 22:05
  • The way to do it is using the comments functionality. So, you tell him the things you want to be changed and he does it. If you want to do it by your own you need a new branch in which you will have both changes and then you can follow my steps. This post may be helps you: http://stackoverflow.com/questions/11066388/how-can-you-add-commits-to-a-github-pull-request-of-another-person-to-your-repo – iberbeu Mar 03 '13 at 22:20