19

I own a repository on GitHub to which someone sent a pull request with one single commit. I only want to implement his solution partially, and use about half of the code changes the user made. What should I do in this situation?

Make a branch of his version, then go back and copy and paste the "old" code that I want to preserve from the original version into a second commit. This may make the diff between commits look larger than it really is, and throw off things like git blame.

Copy and paste the code I want to keep from his commit into a new, different commit. This means that he does not receive credit for his valuable contribution to the code.

Same as the above, copy some of his code into a new commit, but change the author of the commit to him instead of me. He technically didn't write the exact code that was committed, so I'm not sure if this is frowned upon. But at least he gets attribution for those lines that are used.

  • 1
    Remember that git distinguishes "author" and "committer". So when you rewrite their commits to only contain what you actually want, they will still be considered authors. And you the committer. – Jan Hudec Oct 10 '13 at 13:41
36

I'd go with option 4: explain to the contributor why his pull request doesn't fit the project's goals (and in the process give the contributor a chance to explain why he thinks it does) and ask him to resubmit a new version containing only the changes which fit the project.

This has three benefits:

  1. You don't have to do the work ;-)
  2. The contributor will get a better understanding of your goals, making it more likely that future contributions don't need any changes
  3. In addition to retaining a sense of ownership, the contributor is acknowledged and recognized as having made a useful contribution. All of which makes them more likely to continue to contribute
  • 3
    A classic example of a social solution to a technical issue. – paul Oct 11 '13 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.