OpenSource Together

Command Palette

Search for a command to run...

Chapter 5: Forking a Repository and Setting Up Locally

Before you can contribute code, you need a local copy of the project.

This guide explains how forking works and how to prepare a project to run on your machine.


Understanding Forks

A fork is your personal copy of a repository.

Forks allow you to:

  • experiment safely
  • make changes without affecting the original project
  • propose changes through pull requests

Forking is a standard open source workflow.


Forking vs Cloning

Forking:

  • creates a copy under your account
  • is required to propose changes to most projects

Cloning:

  • creates a local copy on your machine
  • does not create a new repository on the platform

Most contributions involve both.


Creating a Fork

To create a fork:

  • use the platform’s fork action
  • create the fork under your account
  • keep the default settings

Once forked, the repository belongs to you.


Cloning Your Fork Locally

After forking, clone the repository:

  • use the repository URL
  • choose a location on your machine
  • verify the clone completes successfully

You now have a local working copy.


Understanding Remotes

Remotes define where your local repository connects.

Common remotes include:

  • origin → your fork
  • upstream → the original repository

Understanding remotes is important for staying in sync.


Adding the Upstream Remote

Adding the upstream remote allows you to:

  • fetch changes from the original project
  • keep your fork up to date

This prevents divergence over time.


Keeping Your Fork Updated

To stay aligned with the original project:

  • fetch changes from upstream
  • merge or rebase as needed
  • update your local branches

Regular updates reduce merge conflicts.


Reading Setup Instructions

Before running anything:

  • read the README setup section
  • check documentation
  • note required versions
  • identify environment variables

Skipping setup instructions causes unnecessary friction.


Installing Dependencies

Most projects require dependencies.

Common steps include:

  • installing packages
  • building assets
  • running setup scripts

Follow instructions exactly before troubleshooting.


Running the Project Locally

Once dependencies are installed:

  • start the project
  • run tests if applicable
  • confirm expected behavior

Successful local setup is a milestone.


Troubleshooting Setup Issues

If setup fails:

  • re-read the documentation
  • search existing issues
  • check error messages carefully
  • ask for help if needed

Setup issues are common and expected.


Avoiding Early Changes

At this stage:

  • do not modify code yet
  • focus on understanding setup
  • verify everything works

Confidence comes from stability.


What You Should Have Now

You should now have:

  • a forked repository
  • a local clone
  • a working development environment
  • a basic understanding of project setup

This is your foundation for contributing.


Reflection

Ask yourself:

  • Which parts of setup were unclear?
  • What assumptions did the project make?
  • What would help future contributors?

These insights often lead to good first contributions.

Earl Grey Badge

You've Completed Chapter 5

Well done! You've learned about forking a repository and setting up locally.

Next Up

6: Making Your First Code Change