The final step in making sure that your changes make it into the project is opening up a pull request. Pull requests compare your branch to the another branch of the repository, allow for your code to be reviewed and any necessary changes to be made, and handle branch merging automatically. The normal process of submitting code to the master branch via pull requests looks like this:
- You push your contributions to your personal branch
- You open up a pull request between your branch and the master branch
- You add reviewers to your code to check it before merging.
- Reviewers either approve or request changes to your code.
- Once the code is approved, you merge your changes into the master branch!
- Open up the branch menu on the repository's home page and select your branch.
- From the bar on top of the branch contents, click the Pull request button.
- Looking at the dropdown menu, set the base branch to
master
and the compare branch to the branch that you made your changes in.
- Add a title and description for your PR.
- Select Create Pull Request (or draft if needed) and you're good to go!
Now, let's say that your need to make some changes to your code you submit the PR. As mentioned in a prior part, all you'll have to make the changes locally and push to your branch, and the updates will automatically be reflected in PR. This is how you make changes brought up in Code Reviews. If you want to learn more about code reviews, see the GitHub Docs: About pull request reviews.
If you don't need to make any changes, the reviewer will approve the PR, and the changes will either be automatically merged in, the reviewer can do it, or you can do it yourself!
Note: If your branch has gotten out of sync with the master branch, you may get a merge conflict. To avoid this, make sure your personal branch up to date with master by runing:
git checkout <your_branch>
git fetch origin
git pull origin master
This is explained further in the next part.
To learn more about merge conflicts, check out the GitHub Docs: About merge conflicts.
Take the changes you pushed to GitHub in the last part and open up a pull request! Hint: if you followed the tutorial, you cloned a fork of this repository. This link might be helpful. If everything checks out, your work in Challenge 3 will be merged into the master branch!