Repositories are great for managing and tracking changes made to code over time. But the real power comes into play when you collaborate with multiple people on a project. When people have multiple improvements, how do we combine them? Pull requests allow contributors to to give back to the main project.
We’ve made some improvements to our version of the Github_Tutorial project. Now let’s click on the Pull Request button to let the owner of the project know about the improvements we’ve made.
Here’s where we describe the changes that we’ve made so that the owner of the main project (SparkFun is the owner in this example) knows what to expect.
As with most comments, be as verbose as possible. The changes you’ve made are obvious to you but to a project owner with thousands of lines of codes and dozens of pull requests it can become confusing.
Once you’ve written a note about the changes you’re proposing click on ‘Send Pull Request’.
Once we’ve sent the pull request, the owner of the main project is notified. Please don’t hesitate to send a pull request to SparkFun for this tutorial. We’d love to hear from you!
This is where the owner of the project can review the submitted code (sometimes called a patch). GitHub provides a great discussion system so that the patch can be discussed. You can even comment on individual lines of code.
Here’s what the pull request looks like from the owner’s point of view. The owner has the option to merge this pull request or discuss it.
In general, create pull requests that are smaller and more simple in nature. This will make it easier for the project owner to wrap their head around. It’s easier to accept pull requests that contain 5 or 10 changes, but a monumental task if you’ve completely rewritten 400 lines of code.