10

I'm new to GitHub. Someone submitted a pull request with 5 commits. 3 of them have a little bug, though, so must wait. How can pick 2 of them for my project?

MaiaVictor
  • 51,090
  • 44
  • 144
  • 286

1 Answers1

8

The ideal solution would be to leave a comment asking for the contributor to submit again his/her pull request with only the 2 commits, in order for you to apply said PR (pull request) without having to do any work.

The other solution, from the page "Merging Pull Request", is to merge locally, on your local clone, in a dedicated branch.
You can then cherry-pick the right commits you want, and push those back to your repo, but make sure to leave a comment in the discussion section of the pull request explaining that

  • you only took 2 of the 5 commits into account,
  • the contributor should rebase his work on top of your new updated master (which now includes said 2 commits), and re-submit the same pull request with the last (and hopefully fixed) 3 commits.

This is similar to the first option, except you don't have to wait for the fixes: you can grab what you want locally, test and push.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • From the OP's description it sounds like the commits are unrelated, otherwise he wouldn't be able to cherry-pick among them anyways. In that case, these should be split into separe pull requests in the first place, so I'd go with your first option to leave a comment requesting the contributor to 1) split the pull requests and resubmit 2) fix the bugs before re-submitting. – Michael Wild Mar 21 '13 at 08:19
  • @MichaelWild I agree, but why wait? Why not grab everything and sort locally? – VonC Mar 21 '13 at 08:20
  • True. If it's not much work, and only a matter of `git add remote ...`, `git fetch ...`, `git cherry-pick ...` (possibly using `-x` to indicate the origin of the patch), why not. – Michael Wild Mar 21 '13 at 08:23