Script Valley
Git and GitHub Complete Course: From Beginner to Advanced
Working with GitHub: Remotes, Push, Pull, and CollaborationLesson 3.3

Forking and Contributing to Open Source

fork, upstream remote, open source contribution, git clone fork, sync fork, contribution workflow

Forking and Contributing to Open Source

Forking is the process of creating your own copy of someone else's repository under your GitHub account. This is the standard way to contribute to open-source projects where you do not have write access to the original repository.

DiagramFork and Upstream Contribution Workflow

IMAGE PROMPT (replace this block with your generated image):

Flat four-actor workflow diagram on white background. Title: Open Source Fork and Contribution Flow. Four boxes arranged in a diamond: Original Repo (top, gray), Your Fork on GitHub (right, #3A5EFF fill), Your Local Clone (bottom, light blue), Upstream (left, dashed border labeled read-only). Numbered arrows: 1. Fork button → creates Your Fork from Original Repo (arrow top to right, labeled Fork on GitHub). 2. git clone → creates Local Clone from Your Fork (arrow right to bottom, labeled git clone). 3. git remote add upstream → connects Local Clone to Original Repo (arrow bottom to left dashed, labeled upstream remote). 4. Feature branch work → Local Clone internal arrow labeled git switch -c feature/fix. 5. git push → Local Clone to Your Fork (arrow bottom to right, #3A5EFF). 6. Pull Request → Your Fork to Original Repo (arrow right to top, green, labeled Open PR). 7. Sync fork → Original Repo to Local Clone (dashed arrow labeled git fetch upstream). White background, numbered circle badges in #3A5EFF.

The Fork and Clone Workflow

On GitHub, click Fork on the target repository. This creates a copy in your account. Then clone your fork locally:

git clone https://github.com/your-username/project-name.git
cd project-name

Adding the Upstream Remote

Add the original repository as a remote called upstream:

git remote add upstream https://github.com/original-owner/project-name.git

Now you have two remotes: origin (your fork) and upstream (the original). You push to origin but pull new changes from upstream.

Syncing Your Fork

Periodically sync your fork with the upstream to stay up to date:

git fetch upstream
git switch main
git merge upstream/main
git push origin main

The Contribution Workflow

Create a feature branch from main, make your changes, push to your fork, and then open a pull request from your fork's branch to the upstream repository's main branch. The project maintainers will review and merge your contribution.

Up next

Pull Requests and Code Review

Sign in to track progress