GitHub Flow - Part 3
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!
Opening a Pull Request (PR)
Overview of Pull Requests
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.
Creating a Pull Request
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.
Writing a Descriptive PR Message
A good PR message guides reviewers through the changes, facilitating a smoother review process. It should include:
- A brief description of the changes
- The reason behind the changes
- Any relevant issue numbers
Code Reviews and Collaborative Work
Responding to Code Reviews
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.
Making Additional Changes
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.
Committing and Pushing Further Changes
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:
git commit -m "Incorporated feedback from code review" git push origin feature-namebash
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.
Note on The firstcontributions Repository
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:
Make necessary changes and commit those changes
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:
git add Contributors.mdbash
Now commit those changes using the
git commit command:
git commit -m "Add your-name to Contributors list"bash
your-name with your name.
Push changes to GitHub
Push your changes using the command
git push -u origin your-branch-namebash
your-branch-name with the name of the branch you created earlier.
Submit your changes for review
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.
Thanks for reading. If you enjoyed this post, I invite you to explore more of my site. I write about web development, programming, and other fun stuff.