Forks let anyone contribute to any public project on GitHub. In this lesson you will fork a repository, set up origin and upstream, open a pull request to the original project, keep your fork in sync and find a good first open-source contribution.
📖 What You’ll Learn: what a fork is, fork vs clone, the full fork workflow, origin and upstream remotes, opening a pull request from a fork, syncing your fork, the gh fork shortcut, finding good first issues, and CONTRIBUTING, code of conduct, CLA and DCO.
🍴 What Is a Fork?
A fork is your own copy of someone else’s repository, under your GitHub account. You have full write access to your fork, even though you cannot push to the original project. Forks are how anyone can contribute to open source:
- Fork the project.
- Make changes in your fork.
- Open a pull request from your fork back to the original project.
| Clone | Fork | |
|---|---|---|
| Where the copy lives | Your computer | Your GitHub account |
| Needs write access to the original to push | Yes | No |
| Used for | Working on repositories you can push to | Contributing to projects you cannot push to |
In practice you fork on GitHub, then clone your fork to your computer.
🧭 The Fork Workflow Step by Step
1. Fork on GitHub
Open the project’s page and click Fork (top right). Keep the name, optionally untick “Copy the main branch only”, and click Create fork.
2. Clone your fork and add upstream
git clone git@github.com:your-username/project.git
cd project
git remote add upstream https://github.com/original-owner/project.git
git remote -v
origin git@github.com:your-username/project.git (fetch)
origin git@github.com:your-username/project.git (push)
upstream https://github.com/original-owner/project.git (fetch)
upstream https://github.com/original-owner/project.git (push)
origin is your fork; upstream is the original project (remotes).
3. Create a branch for your change
git switch -c fix/typo-in-readme
# make the change
git add README.md
git commit -m "Fix typo in installation steps"
git push -u origin fix/typo-in-readme
💡 Tip: Never work directly on main in a fork. Keep main identical to the original project and use one branch per contribution.
4. Open the pull request
GitHub shows Compare & pull request on your fork. Check that the base repository is the original project (and its main) and the head repository is your fork and branch. Write a clear description, reference the issue (Fixes #123), and submit.
5. Respond to review
Maintainers may ask for changes. Push more commits to the same branch; the PR updates automatically (code review).
🔄 Keep Your Fork Up to Date
The original project keeps moving. Sync your fork before starting new work:
git switch main
git fetch upstream
git merge upstream/main # or: git rebase upstream/main
git push origin main
Or click Sync fork on your fork’s GitHub page, then git pull locally. To update a feature branch: git rebase main (then git push --force-with-lease), as in git rebase.
⚡ Shortcut with the GitHub CLI
gh repo fork original-owner/project --clone # fork, clone and add upstream in one step
gh pr create --fill # open a PR to the original repository
🌍 Finding Your First Open-Source Contribution
- Look for issues labelled good first issue or help wanted (search
label:"good first issue"on GitHub). - Start small: documentation fixes, typos, examples, missing tests.
- Testers have a natural advantage: reproducing bugs, writing failing tests, and improving test coverage are valuable contributions.
Before you start
| File | Why read it |
|---|---|
README.md | How to set up and run the project |
CONTRIBUTING.md | How the maintainers want contributions: branch names, commit style, tests |
CODE_OF_CONDUCT.md | Community behaviour rules |
| Open issues and PRs | Avoid duplicating work; comment on an issue before starting a big change |
Some projects require a CLA (Contributor License Agreement) or a DCO sign-off (git commit -s adds a “Signed-off-by” line). The PR checks will tell you.
📝 Assignment
- Fork any public repository (for example a practice repository from a friend, or GitHub’s own example projects) and clone your fork.
- Add the original repository as
upstreamand confirm withgit remote -v. - Create a branch, fix a typo or improve a README, push it and open a pull request to the original repository (or to your own second repository if you prefer not to contact maintainers yet).
- Sync your fork’s
mainwithupstreamusing the commands above and with the Sync fork button. - Find three issues labelled “good first issue” in projects related to testing or Playwright.
❓ FAQ
🤔 What is a fork in GitHub?
A copy of another user’s repository in your own GitHub account, which you can change freely and use to propose changes back with a pull request.
🤔 What is the difference between fork and clone?
A fork is a server-side copy on GitHub under your account. A clone is a local copy on your computer. You usually fork first, then clone your fork.
🤔 How do I keep my fork updated?
Add the original as upstream, then git fetch upstream, git merge upstream/main on your main branch and git push origin main, or use Sync fork on GitHub.
🤔 How do I contribute to open source on GitHub?
Find an issue, read CONTRIBUTING.md, fork the repository, make the change on a branch, push it to your fork and open a pull request to the original project.
🤔 Can I make a pull request without forking?
Only if you have write access to the repository; then you push a branch directly and open the PR from it.
🎯 Next Steps
- 🗂️ GitHub Issues, Labels and Projects
- 📝 Markdown and Writing a Great README
- 📘 Git and GitHub Tutorial: full course
🎬 Learn Git and GitHub step by step: watch the series on YouTube!
Subscribe to SqaToolsByDY • Practice on sqatools.in