# Fork vs Branch

> What is the difference between a fork and a branch? When would you use each in open-source contributions?

Canonical: https://www.internhack.in/learn/interview/open-source-interview/oss-fork-vs-branch
Last updated: 2026-11-28

Difficulty: Beginner

## Question

What is the difference between a fork and a branch? When would you use each in open-source contributions?

## Answer

A fork is a server-side copy of an entire repository under your GitHub account, while a branch is a lightweight pointer to a specific commit within a single repository.

Forks are used when you don't have write access to the upstream repository — which is the case for most open-source contributions. You fork the repository, clone your fork, make changes, and submit a PR from your fork's branch to the upstream repository. The fork serves as your personal workspace.

Branches are used within a repository to isolate changes. In a forked repository, you create branches for each feature or fix you're working on. In the upstream repository, maintainers use branches to manage their development workflow.

If you have write access (e.g., within your team's repository), you can work directly in branches without forking. But for external open-source contributions, the fork-and-PR model is standard because it respects the maintainers' control over their repository.

## Key points

- Fork = copy of the entire repo under your account (server-side)
- Branch = pointer to a commit within a repo (lightweight)
- External contributors must fork due to permission restrictions
- Team members with write access can use branches directly

## Common follow-up questions

- How do you sync your fork with the upstream repository?
- Can you have multiple forks of the same repository?
- How do you delete a fork after it's been merged upstream?

## Interview tips

- Clearly distinguish between server-side (fork) and local (branch) concepts
- Explain the permission model — fork when no write access, branch when you have it
- This is a fundamental question — be precise and confident

## Concepts covered

Fork, Branch, Permissions, Collaboration Model

Previous: [Handling a Rejected PR](https://www.internhack.in/learn/interview/open-source-interview/oss-rejected-pr) · Next: [Finding Good First Issues](https://www.internhack.in/learn/interview/open-source-interview/oss-find-good-issues) · [All of Open Source Contribution](https://www.internhack.in/learn/interview/open-source-interview)

## More Open Source Contribution questions

- [What Makes a Good PR Description?](https://www.internhack.in/learn/interview/open-source-interview/oss-good-pr-description)
- [Why Open Source?](https://www.internhack.in/learn/interview/open-source-interview/oss-open-source-mindset)
- [Walk Me Through Your Contribution Process](https://www.internhack.in/learn/interview/open-source-interview/oss-contribution-process)
- [Reading an Unfamiliar Codebase](https://www.internhack.in/learn/interview/open-source-interview/oss-read-unfamiliar-codebase)
- [Writing a Good First-Time Issue Comment](https://www.internhack.in/learn/interview/open-source-interview/oss-good-first-issue)
- [Git Workflow for Contributing](https://www.internhack.in/learn/interview/open-source-interview/oss-git-workflow)

## Related

- [Learn](https://www.internhack.in/learn)
- [Interview Prep](https://www.internhack.in/learn/interview)
- [Open Source Contribution](https://www.internhack.in/learn/interview/open-source-interview)
