Search code examples
ruby-on-railsgitgithubcherry-pick

If I create a pull request on a repository, if the admins decide to include only some of the commits, will that still count as a contribution for me?


I want to make a contribution to the Rails repository in a very specific file. That contribution should be split on various commits. If I create the pull request and say the admins decide than only some commits are good to merge, will they be able to only merge some of the commits? And will that contribution count on my profile or should I split my contribution into several pull requests for them to choose the changes that are worth?

I've read about they could cherry-pick some of my commits but I'm not sure if that would count as a contribution on my profile.

Thanks for your answers


Solution

  • GitHub does not natively provide a way to merge only part of a pull request. However, it is possible for a maintainer to manually cherry-pick one or more commits into their repository, in which case you would be listed as the author and they would be listed as the committer.

    Usually, though, if there are changes the maintainers don't want, they'll ask you to force-push your branch with only the changes they'd like to keep. Open source maintainers are usually busy enough that manually cherry-picking pieces is a hassle and it can often lead to conflicts which they don't want to resolve manually. Making you polish your submission is easier and puts the burden on you to create a quality submission.

    It's also fine if your pull request gets reviewed and needs some changes. I contribute to Git on a regular basis, and almost nobody submits a patch and has it picked up immediately without changes. I recently sent 5 versions of a series before it was finally accepted. The review process is a chance for everyone involved to come to a set of changes that they feel good about and can be proud of.

    GitHub does count contributions for which you are the author, even if someone else is the committer. The Git project itself uses a patch-based workflow where the maintainer accepts and applies patches from contributors, making the contributor the author and the maintainer the committer. These contributions are reflected on the author's GitHub profile just like any other contribution. Do note that only commits that end up in the default branch (usually master) are counted.

    In general, if you're unsure about what the maintainers of the project are looking for in a particular submission, you can open an issue and discuss your proposal (unless the contributing documentation says otherwise). That's often helpful both for you and the maintainers, because you don't write code you need to throw away and the maintainers get a quality contribution that meets their needs earlier on.