This content originally appeared on DEV Community and was authored by Dieke Sydney
In open-source collaboration, you might encounter a situation where you want to suggest changes to someone else’s pull request (PR). If you have write access to the repository, you can push directly to the PR branch. But what if you don’t? This guide walks you through the process of creating a “pull request to a pull request” when you don’t have write access.
Why Would You Do This? ¯(ツ)_/¯
- To contribute improvements to an existing PR before it gets merged.
- To fix small issues (typos, bugs, or missing features) in someone else’s PR.
- To collaborate in a review-driven workflow.
Cautions Before You Start
Before contributing to another pull request, keep these points in mind:
- Respect the Author’s Work: You’re modifying someone else’s contribution. Make sure your changes are helpful and aligned with the purpose of their PR.
- Communicate First: If possible, comment on the original PR to let the author know you’d like to contribute improvements. This avoids misunderstandings.
- Check for Active Updates: The author might already be working on similar changes. Pull the latest branch updates before making edits.
- Keep Changes Minimal: Focus only on what’s necessary to fix or improve the PR. Avoid adding unrelated features.
-
Follow the Project’s Contribution Guidelines: Check the repository’s
CONTRIBUTING.md
or style rules so your PR isn’t rejected for formatting or process issues. - Test Your Changes: Ensure your update doesn’t break existing functionality before submitting.
- Be Ready for Feedback: The author or maintainers may request changes, and that’s part of the collaborative process.
Here’s a step-by-step guide
To demonstrate how to make a PR on another PR without write access, let me walk you through the exact steps I followed when contributing to a PR (typescript-sprint) on freeCodeCamp’s CurriculumExpansion
CurriculumExpansion repository
1. Fork the Repository
Since you don’t have write access, the first thing you want to do is to fork the repository:
- Go to the repository containing the PR you want to contribute to.
- Click the Fork button (top right corner).
This creates a personal copy of the repository under your account
2. Clone Your Fork
Run the below command on your Command Line Interface (CLI):
git clone https://github.com/Your-Username/Repo-Name.git
cd Repo-Name
3. Add the Original Repository as a Remote
This will let you pull changes from the original repository (including the PR branch).
git remote add upstream https://github.com/Original-Owner/Repo-Name.git
4. Fetch the PR Branch
Find the branch name from the PR you want to modify.
git fetch upstream Branch-Name
5. Create your own branch
Make your own branch where you can save your changes
git checkout -b Your-Branch upstream/Branch-Name
5. Make Your Changes
Edit the files.
Stage your changes:
git add .
- Commit your changes:
git commit -m "Describe your change briefly"
6. Push to Your Fork
git push origin Your-Branch
7. Create Your Pull Request
- Go to your fork on GitHub.
- Click Compare & pull request.
- In the PR creation page:
- Base repository → the original repository.
-
Base branch → the PR’s branch (not
main
).
This allows you to target the original PR branch, even though you’re not a direct collaborator.
- Write a short description of your changes and submit for review.
8. Wait for Feedback
Once all that is done, actively wait for feedback on your PR with fingers crossed, and hopefully, it will be merged.
Conclusion
Even without write access, you can still enhance someone else’s PR and help move the project forward, and this guide ensures smooth collaboration and keeps the development process inclusive.
Open source thrives when everyone can contribute, even to contributions themselves!
This content originally appeared on DEV Community and was authored by Dieke Sydney