Forking Workflow
Each contributor works on their own fork and proposes changes via Pull Request to the main repository.
Context
Open source projects or projects with external contributors who should not have write access to the main repo.
Solution
- Each person forks the repo and works on their copy.
- Changes reach the main repo (
upstream) via Pull Request. - Maintainers review and merge; everyone else has read-only access.
- Inside the fork, GitHub Flow is commonly used.
BASH
git remote add upstream https://github.com/org/project.git
git fetch upstream
git switch -c fix/typo upstream/main
git push origin fix/typo # then open a PR against upstream
When NOT to use it
- Trusted internal teams: forks add friction (keeping the fork in sync) with no benefit. Use branches in the same repo.
Tradeoffs
| Pro | Con |
|---|---|
| Full control over who writes to the main repo | Keeping the fork in sync |
| Ideal for external contributors | More steps to contribute |
| Scales to large communities | CI on fork PRs has secret restrictions |
#git #branching #open-source #fork