Git - Do you know when to create a fork vs a branch?

Updated by Brady Stroud [SSW] 1 year ago. See history

123

When starting to work on a project, it's common to wonder whether to fork an existing repository or create a new branch for it. Before making this decision, it's important to consider the key differences between the two options.

Figuring out whether to fork or branch

Generally, branching is a default option if you're working on a team developing a product. However, if you run into someone else's product and have new ideas you want to try, then forking is a good option because you can work on your ideas in isolation.

Tip: If unsure ask yourself 3 questions... If your answer is 'no' to any of the following questions, then you should go for a fork:

  1. Do you have access to the existing repository to clone a new branch?
  2. Is the change going to be part of that project and has it been approved by the Product Owner?
  3. Do you or anyone you're working with on that project own the existing repository?

Summary - Forking vs Branching

ForkBranch
PurposeCreate a separate copy of a repository for significant changes or different directionsDevelop new features or fix bugs without disrupting the main codebase
Relationship to the original codebaseCompletely independent repositoryLinked to the original repository
OwnershipOwned by the user who created themOwned by the repository owner
Scope of changesTypically involve significant changesTypically involve smaller changes
CollaborationUsed to develop ideas in isolation from the main teamUsed to develop ideas that the main team is working on