Collaboration and Open Source
6 learning objectives · 10 key terms · 7 commands · 3 diagrams · 5 quiz questions
Collaboration and Open Source
CollaborationWhat you'll be able to do
- Fork a repository and explain how a fork differs from a clone
- Add and manage an upstream remote so your fork stays current
- Make a contribution on a branch and open a pull request from your fork
- Find beginner-friendly projects to contribute to
- Follow contribution guidelines, code of conduct and maintainer etiquette
- Respond to review feedback without taking it personally
The idea, in plain language
You cannot push to a repository you do not own, and that is the whole reason forks exist. Forking copies someone else's repository into your own GitHub account, where you have full write access. Your fork keeps a link back to the original — conventionally named upstream — so you can pull in changes from a project you do not control. A clone is a copy on your laptop; a fork is a copy in your account. Contributing to a large project normally uses both: fork, clone your fork, branch, push to your fork, then open a pull request from your fork into the original.
Keeping the fork current is a habit, not an event. Fetch from upstream, merge or rebase main, push to your fork's main, then update your feature branches by rebasing them onto it. Do this before opening a pull request, and again if the maintainers merge other work while your pull request is in review. A stale fork is the most common reason a first contribution ends in a conflicted mess that nobody wants to resolve.
The human side matters just as much. Successful contributors read CONTRIBUTING.md before writing code, run the project's tests, keep each change small and single-purpose, and follow the issue they are fixing. Maintainers are usually volunteers working through a queue; a clear pull request with a good description is a gift, and a "why is this not merged yet?" comment is not. When review feedback arrives, treat it as information about the code, not a judgement of you — the reviewers are telling you exactly what the project expects, which is the fastest possible way to learn its standards.
Key terms
- Fork
- A copy of someone else’s repository in your own GitHub account, with your own write access.
- Clone
- A copy of a repository on your computer.
- upstream
- The remote pointing at the original repository your fork came from.
- origin
- Here, your own fork — the remote you can push to.
- Contribution guidelines
- CONTRIBUTING.md: how the project wants changes proposed, tested and formatted.
- Code of conduct
- The behavioural rules for participating, with a route to report violations.
- Maintainer
- Someone with write access who reviews and merges contributions.
- Good first issue
- A label maintainers use to mark work suited to a newcomer.
- Synchronising a fork
- Pulling upstream changes into your fork’s main branch.
- CLA / DCO
- A contributor licence agreement or Developer Certificate of Origin some projects require, signed off with git commit -s.
How it works, step by step
- 1Read before you fork
Open README.md, CONTRIBUTING.md and the code of conduct. Check whether issues marked good first issue exist, and whether the project asks for an issue before a pull request. Five minutes here saves a rejected contribution.
- 2Fork, then clone your fork
Forking happens on GitHub; cloning happens on your machine. Clone the fork, not the original, because that is where you can push.
fork and clonebashgh repo fork owner/project --clone cd project
- 3Add the original as upstream
Your clone knows about your fork as origin. Add the original project as upstream so you can pull its changes.
wire up upstreambashgit remote add upstream https://github.com/owner/project.git git remote -v # origin https://github.com/ada/project.git (fetch) # upstream https://github.com/owner/project.git (fetch)
- 4Branch from an up-to-date main
Sync first, then branch. A branch cut from a month-old main is the classic first-contribution mistake.
sync, then branchbashgit fetch upstream git switch main git merge --ff-only upstream/main git push origin main git switch -c fix/typo-in-readme
- 5Make the change the project asked for
Follow the project's style, run its tests and linters, and keep the change narrowly scoped to the linked issue. Commit with a message matching the project's conventions.
one scoped changebashgit add README.md git commit -s -m "docs: fix broken install link" git push -u origin fix/typo-in-readme
- 6Open the pull request against upstream
The base repository must be the original project, not your fork. Fill in the project's pull request template, link the issue, and say what you tested.
open the PRbashgh pr create --repo owner/project --base main --head ada:fix/typo-in-readme
- 7Respond, iterate, and thank the reviewer
Push fixes as new commits on the same branch, reply to each comment, and resolve discussions once handled. If the maintainers are slow, wait — a polite nudge after a couple of weeks is fine; a daily ping is not.
keep the branch currentbashgit fetch upstream git rebase upstream/main git push --force-with-lease origin fix/typo-in-readme
Commands worth memorising
Every block below is copy-ready — use the Copy button, then paste it into your terminal. Expected output is shown underneath so you know what “working” looks like.
gh repo fork owner/project --clone
✓ Created fork ada/project Cloning into 'project'...
Creates your fork and clones it with origin pointing at your copy.
git remote add upstream https://github.com/owner/project.git
The original repository. Fetch from it, never push to it.
git fetch upstream git switch main git merge --ff-only upstream/main git push origin main
Updating 3f9a1c2..8c1d2ab Fast-forward README.md | 4 ++--
--ff-only refuses to invent a merge commit if your main diverged — which should never happen on a fork.
git rebase upstream/mainReplays your contribution on top of the newest upstream code. Resolve any conflicts locally, then force-push with --force-with-lease.
git push --force-with-lease origin fix/typo-in-readme
Refuses if someone else pushed to the branch since your last fetch. Always prefer this over plain --force.
gh pr create --repo owner/project --base main --head ada:fix/typo-in-readme --title "docs: fix broken install link"
https://github.com/owner/project/pull/4127
Note the --head owner:branch form — that is how you name a branch on a fork.
gh issue list --repo owner/project --label "good first issue" --limit 10
4096 Document the --json flag for list commands good first issue 4088 Add a test for empty input good first issue
Find work the maintainers have explicitly marked as suitable for newcomers.
Workflow diagrams
Three copies of the same repository are in play: the original, your fork, and your laptop. Knowing which one each command talks to is the whole skill.
- Fork the upstream repository into your own account.
- Clone your fork, and add upstream so you can pull the original’s changes.
- Cut a feature branch and make one scoped change.
- Push to your fork and open a pull request whose base is the upstream repository.
- Iterate on review feedback by pushing more commits, then rebase once the maintainers have merged other work.
- When it is merged upstream, sync your fork and delete the branch.
| Copy | Remote name | You can push? | Commands aimed at it |
|---|---|---|---|
| Original project | upstream | No | git fetch upstream, git rebase upstream/main |
| Your fork | origin | Yes | git push origin main, git push -u origin <branch> |
| Your laptop | — | n/a | git switch, git add, git commit, git log |
| Pull request target | — | n/a | --repo owner/project, --base main |
Almost every first-time contribution problem is a command aimed at the wrong copy.
- Fetch and rebase from upstream; push only to origin.
- Branch and commit locally, then push the branch to your fork.
- Open the pull request with the base repository set to the original project.
| Do | Do not |
|---|---|
| Read CONTRIBUTING.md and follow it | Assume the project works like your last one |
| Open or claim an issue before large work | Surprise maintainers with a 3,000-line refactor |
| One change per pull request | Bundle a feature, a rename and a formatting pass |
| Run the project’s tests and say so | Submit untested code and let CI find it |
| Reply to every review comment | Silently resolve comments and push |
| Be patient with a volunteer queue | Ping daily asking for a merge |
The technical work is half of it; the other half is making the change easy to accept.
- Preparation (reading the guidelines, one scoped change) does more for merge speed than clever code.
- Communication keeps a contribution alive: reply, iterate, and be explicit about what you changed.
Worked example
A complete first contribution to somebody else’s project, from fork to merge.
gh repo fork owner/project --clone cd project git remote add upstream https://github.com/owner/project.git git fetch upstream git switch main git merge --ff-only upstream/main git push origin main git switch -c docs/fix-install-link # ... fix the broken link in README.md ... git add README.md git commit -s -m "docs: fix broken install link" git push -u origin docs/fix-install-link gh pr create --repo owner/project \ --title "docs: fix broken install link" \ --body "The npm install link 404s. Points at the current package page. Closes #4096." # maintainer merges it; sync up afterwards git switch main git fetch upstream git merge --ff-only upstream/main git push origin main git branch -d docs/fix-install-link
The change is merged upstream, your fork matches upstream exactly, and your board is clean.
Where you'll use it
Common mistakes
- Cloning the original repository instead of your fork, then having nowhere to push.
- Never adding an upstream remote, so your fork drifts months behind and the pull request is full of conflicts.
- Opening a pull request from your fork’s main branch, which makes it hard to keep the branch updated and breaks your own main.
- Submitting a large unsolicited refactor the project never asked for.
- Ignoring CONTRIBUTING.md, so the pull request arrives in the wrong branch or without tests.
- Using git push --force on a branch under review and wiping the reviewer’s line comments.
- Commenting "any update?" every day on a pull request maintained by volunteers.
Best practices
- Read README, CONTRIBUTING and the code of conduct before writing any code.
- Fork, clone your fork, add upstream, then branch from freshly synced main.
- One contribution per branch, named after the issue.
- Reuse the project’s pull request template and run its test suite locally.
- Use git push --force-with-lease after a rebase, never a bare --force.
- Reply to every review comment, and thank reviewers — they are the reason your change ships.
- Sync your fork after the merge so the next contribution starts clean.
Hands-on exercise
Ship one small contribution to a real project
Find something genuinely useful to fix — documentation counts, and is often the best place to start.
- Find a repository with a good first issue label or a documentation typo you have personally noticed.
- Read CONTRIBUTING.md and the code of conduct, and check whether the project wants an issue opened first.
- Fork and clone it, add upstream, sync main, then create a branch named after the issue you are fixing.
- Make the smallest change that solves it. Run the project’s tests or lint command and note the result.
- Commit following the project’s message conventions, push to your fork, and open a pull request against the upstream base branch using the project’s template.
- When a review arrives, reply to each comment, push any requested fix as a new commit, and reply again once it is done.
💡 Hint: Contributing to a project you already use is easier: you understand the problem, and the maintainers recognise the context in your pull request.
Done when: Your pull request is open against the upstream repository with a linked issue, the project’s tests pass, and you have replied to every review comment.
Checkpoint quiz
0 of 5 answered · 0 correct
- Multiple choiceQ1
What is the difference between forking and cloning?
- Command outputQ2
What does this sequence accomplish?
git fetch upstream git switch main git merge --ff-only upstream/main git push origin main
- TroubleshootingQ3
After rebasing your branch you need to push it back to your fork. Which command is safest?
- True or falseQ4
True or false: you can push directly to the original repository you forked from.
- Multiple choiceQ5
What should you do before starting work on a large contribution to an unfamiliar project?
Module summary
- Fork = a copy in your account; clone = a copy on your disk; contributing needs both.
- Add the original project as upstream, fetch from it, and push only to origin.
- Sync your fork before branching, and rebase your branch on upstream before opening the pull request.
- Open the pull request against the upstream base branch, not just your fork.
- --force-with-lease is the safe force-push after a rebase.
- Read CONTRIBUTING.md, keep one change per pull request, reply to every comment, and be patient with volunteer maintainers.
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Put the GitHub course to work: open one of the company-wise repositories and follow the workflow you just learned, branch to release.