September 15, 2023
O. Wolfson
In the previous article, we successfully created a new branch and began working on our feature using GitHub Flow. In this segment, we take it a step further to the heart of collaboration – opening a pull request (PR) and fostering collaborative work through code reviews. Let’s get started!
Pull requests are the gateway to collaboration in GitHub Flow. When you open a PR, you're proposing your changes and requesting that someone review and pull in your contribution. PRs show diffs, or differences, of the content from both branches.
To create a pull request, navigate to the "Pull requests" tab in your GitHub repository and click "New pull request." Select the branch that contains your changes, and target the main branch where you want to merge your changes.
A good PR message guides reviewers through the changes, facilitating a smoother review process. It should include:
Once your PR is open, other developers can review your changes and provide feedback. It's crucial to engage constructively with reviews to foster a collaborative environment.
Based on the feedback, you might need to make additional changes. Update your branch with the necessary revisions and push your changes to update the PR automatically.
If further modifications are required, repeat the process of making changes locally, committing them, and then pushing them to your GitHub repository to update the PR.
Use the following commands to commit and push your changes:
bashgit commit -m "Incorporated feedback from code review"
git push origin feature-name
In this installment of our GitHub Flow series, we ventured into the collaborative heart of GitHub - opening pull requests and engaging in collaborative code reviews. In our next article, we will explore the final steps: merging the PR and reflecting on the collaborative process.
Since we are working with the firstcontributions repository, we can follow the instructions from their README.md. These instructions closely mirror what we are trying to do in the article above, but are specific instructions for working with the firstcontributions repo. Open the firstcontributions repository and see the README.md
file, or click here.
Here is an excerpt from the README.md file:
Now open Contributors.md
file in a text editor, add your name to it. Don't add it at the beginning or end of the file. Put it anywhere in between. Now, save the file.
If you go to the project directory and execute the command git status
, you'll see there are changes.
Add those changes to the branch you just created using the git add
command:
bashgit add Contributors.md
Now commit those changes using the git commit
command:
bashgit commit -m "Add your-name to Contributors list"
replacing your-name
with your name.
Push your changes using the command git push
:
bashgit push -u origin your-branch-name
replacing your-branch-name
with the name of the branch you created earlier.
If you go to your repository on GitHub, you'll see a Compare & pull request
button. Click on that button.
Now submit the pull request.
Soon I'll be merging all your changes into the main branch of this project. You will get a notification email once the changes have been merged.