Version Control – Etiquette for Editing Someone’s Pull Request on GitHub

etiquettegitgithubversion control

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.

Best Answer

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
Related Topic