LearnAI ToolsCareerPractice BuildsPlayDevelopmentContact
Git & GitHubBeginner~1 hour

Your First Open-Source Contribution

Fork a practice repository, add your name on a branch, open a pull request to the original project and keep your fork in sync after it is merged.

ForksUpstream RemotesSyncingPull Requests

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.

Follow the Repository’s Own Instructions Too

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.git
cd first-contributions
Output

Click Run to see what this code prints.

Step 2: Add the Upstream Remote

git remote add upstream https://github.com/firstcontributions/first-contributions.git
git remote -v
Output

Click Run to see what this code prints.

Step 3: Make Your Change on a Branch

git switch -c add-priya-sharma
Output

Click 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 diff
Output

Click Run to see what this code prints.

git commit -am "Add Priya Sharma to Contributors list"
Output

Click Run to see what this code prints.

Step 4: Push and Open the Pull Request

git push -u origin add-priya-sharma
Output

Click Run to see what this code prints.

  1. Open your fork on GitHub and click “Compare & pull request”.
  2. Check the header: base repository firstcontributions/first-contributions, base main ← head repository your fork, compare add-priya-sharma.
  3. Keep the title from your commit, add a short friendly description, and click “Create pull request”.
  4. Wait for a maintainer (or the project’s automation) to review and merge it, and reply politely to any comments.
Mini Challenge · Put It in Order

Put the contribution steps in order.

  1. Push the branch to your fork
  2. Edit, review with git diff and commit
  3. Fork the repository on GitHub
  4. Open a pull request to the original repository
  5. Create a branch for your change
  6. 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 main
git fetch upstream
Output

Click Run to see what this code prints.

git merge upstream/main
git push origin main
Output

Click 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-sharma
git push origin --delete add-priya-sharma
Output

Click Run to see what this code prints.

git log --oneline --graph -5
Output

Click 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.