Overview
Your first open-source pull request is a milestone, and there is a project that exists purely so beginners can practise it safely: firstcontributions/first-contributions on GitHub, where you add your name to a contributors list. In this project you will go through the complete fork-and-pull-request workflow from lesson 13, from forking to keeping your fork in sync after the maintainers merge your work.
Practice repositories update their instructions from time to time. If the README asks for something slightly different (for example, a different file to edit), follow the README — the Git commands stay exactly the same.
Prerequisites
- A GitHub account with authentication set up — lessons 10 and 11.
- Branches and pull requests — lessons 7 and 12.
- Forks, origin and upstream — lesson 13.
Step 1: Fork and Clone
Open github.com/firstcontributions/first-contributions, click Fork, and create the fork under your account. Then clone your fork (with your username in the URL):
git clone https://github.com/priya-sharma/first-contributions.gitcd first-contributionsClick Run to see what this code prints.
Step 2: Add the Upstream Remote
git remote add upstream https://github.com/firstcontributions/first-contributions.gitgit remote -vClick Run to see what this code prints.
Step 3: Make Your Change on a Branch
git switch -c add-priya-sharmaClick Run to see what this code prints.
Open Contributors.md and add your name on a new line somewhere in the middle of the list — adding to the middle rather than the end makes conflicts with other contributors less likely. Check your change:
git diffClick Run to see what this code prints.
git commit -am "Add Priya Sharma to Contributors list"Click Run to see what this code prints.
Step 4: Push and Open the Pull Request
git push -u origin add-priya-sharmaClick Run to see what this code prints.
- Open your fork on GitHub and click “Compare & pull request”.
- Check the header: base repository firstcontributions/first-contributions, base main ← head repository your fork, compare add-priya-sharma.
- Keep the title from your commit, add a short friendly description, and click “Create pull request”.
- Wait for a maintainer (or the project’s automation) to review and merge it, and reply politely to any comments.
Put the contribution steps in order.
- Push the branch to your fork
- Edit, review with git diff and commit
- Fork the repository on GitHub
- Open a pull request to the original repository
- Create a branch for your change
- Clone your fork
Step 5: After the Merge
Once your pull request is merged — and other people’s keep arriving — your fork falls behind. Bring your main up to date from upstream and push it to your fork:
git switch maingit fetch upstreamClick Run to see what this code prints.
git merge upstream/maingit push origin mainClick Run to see what this code prints.
Your branch has done its job. Delete it locally and on your fork:
git branch -d add-priya-sharmagit push origin --delete add-priya-sharmaClick Run to see what this code prints.
git log --oneline --graph -5Click Run to see what this code prints.
There it is in the project’s history: the maintainer’s merge commit for your pull request, followed by the next contributor. Your fork’s main is identical to upstream again, ready for your next contribution.
Extend This Project
- Search GitHub for issues labelled “good first issue” in a tool you use, and claim one by commenting before you start.
- Fix a typo or unclear sentence in a project’s documentation — a real, welcome contribution.
- Read a project’s CONTRIBUTING.md and follow its commit-message and testing rules in your next pull request.
Summary
You forked a project, contributed on a branch, opened a pull request to a repository you do not own and kept your fork in sync afterwards. This is the exact process used for contributions to Linux, Python, React and thousands of other projects.