Say you've got a user who made a few commits and rolled them into one pull request. You want to accept one of the commits, but reject the others. Is this possible with GitHub?
Asked
Active
Viewed 1.3k times
32
-
2This is more of a Git activity than GitHub. – phwd Aug 27 '11 at 20:01
2 Answers
25
Next to the "Merge pull request" button, there should be a "Use the command line" link to instructions on how to do it manually. You should follow these instructions (create new local branch and pull in their changes), but then instead of merging that whole branch back into master, you just cherry-pick the commits you want.
e.g. to review a pull request from user: jashkenas, in their branch: new-feature
git checkout -b jashkenas-new-feature master
git pull https://github.com/jashkenas/YOUR_REPO_NAME.git new-feature
And then do your testing, and then when you're ready:
git checkout master
git cherry-pick COMMIT_HASH_1
git cherry-pick COMMIT_HASH_2
# etc
git push origin master

jackocnr
- 17,068
- 10
- 54
- 63
-
I think when we `cherry-pick` a commit, it merges that commit into master? What if there are conflicts, would it prompt to resolve those? – eMad Sep 04 '17 at 18:45
-
@eMAD if you're going to be dealing with conflicts, it's probably easier to do an interactive rebase on the feature branch, and drop the other commits and handle any conflicts there, and then merge that branch into master. – jackocnr Sep 05 '17 at 13:53
16
Yes, you can manually accept certain commits using git-cherry-pick
and then close the pull request.

user1284631
- 4,446
- 36
- 61

Ciaran
- 1,904
- 16
- 27