Learning Git: What Is a Pull Request?
Perfect for those just starting out with collaborative development, let's walk through a basic topic: pull requests.
Join the DZone community and get the full member experience.Join For Free
Whether you’re collaborating on a work assignment with colleagues or contributing to an open-source project, chances are that you will be operating in the following scenario. You make local code changes and then submit those changes to a remote project maintainer for review before those changes are implemented, or merged.
This is called a pull request; you are requesting that someone reviews and approves your changes before they become final.
Watch this video to learn more about what a pull request is, or keep reading.
While pull requests are not a core feature of Git, they are commonplace when it comes to collaborating with Git hosting services. They are especially necessary when working with open-source projects.
Let’s say, for example, that you want to contribute to your favorite open-source project in GitHub. Most open-source projects have a maintainer who can control which changes are approved and merged into the project. They have the control to approve and decline changes as they wish.
How Do I Get Changes Approved With a Pull Request?
After forking the repository on the remote hosting service and cloning it to your local machine, you can start working on making changes to the code.
After you’re happy with the changes, you can push the work up to your fork and open a pull request that will signal the main repo. This pull request asks the maintainer(s) to review your work, provide comments, request edits, etc.
If your pull request is approved, the maintainer will merge your changes into the main repo.
Why Should I Use Pull Request Templates?
Many repos have guidelines for submitting pull requests, requiring the inclusion of a description which should clearly describe what the maintainer can expect when reviewing the code and any standards you, as the developer, have considered before submitting the pull request.
Some projects may even require the use of formalized templates in order to submit proposed changes. A template could include a description checklist, requesting details such as:
- How a bug was fixed or summary of a new feature.
- Unit test cases.
- Whether it was tested on all devices and browsers.
Published at DZone with permission of Jonathan Silva, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.