What Is a Fork? - How to Customize Open Source Projects
A fork is a GitHub feature that copies another developer’s repository into your own account. The copied repository becomes yours to change freely, while keeping its connection to the original repository (the upstream).
It is used when customizing open source projects or contributing to projects you are interested in.
Environment Preparation
Section titled “Environment Preparation”Prepare Node.js and Git on Mac. Using nvm for Node.js version management is convenient.
nvm install 20 # Install Node.js 20 LTS
nvm use 20 # Select the installed version
node -v # Check versionCheck that Git is available:
git --versionIf Git is not installed, install it with brew install git.
Fork the Original Project
Section titled “Fork the Original Project”- Open the repository you want to fork on GitHub
- Click the Fork button in the upper-right corner
- Select your account, and a copy will be created under your account
- If you want to rename the repository, you can do that in Settings
💡 The forked repository remains linked to the original, but changes from the original will not appear in your fork unless you pull them in yourself.
Clone the Forked Repository
Section titled “Clone the Forked Repository”After forking, clone the repository in your account to your local machine.
git clone https://github.com/you/forked_repo.git
cd forked_repoRegister the original repository as upstream so you can pull in later updates.
git remote add upstream https://github.com/someone/original_repo.git
git remote -vIf it is configured correctly, you will see:
origin https://github.com/you/forked_repo.git (fetch)
origin https://github.com/you/forked_repo.git (push)
upstream https://github.com/someone/original_repo.git (fetch)
upstream https://github.com/someone/original_repo.git (push)Install Dependencies and Verify It Works
Section titled “Install Dependencies and Verify It Works”For JavaScript projects, install the dependencies:
npm install
npm run dev # Start the dev server and verify it works💡 The command started by
npm run devdepends on the project. Check thescriptssection ofpackage.json.
Customize the Project
Section titled “Customize the Project”Because the forked repository is yours, you can change it freely. For example, if you add content in Markdown, it might look like this:
---
title: "My First Post"
date: "2026-04-01"
---
This is my first post.After making changes, commit and push them:
git add .
git commit -m "Add content"
git push origin mainPull in Upstream Updates
Section titled “Pull in Upstream Updates”If the original repository changes, you can bring those changes into your fork.
git checkout main
git fetch upstream
git merge upstream/main
git push origin main| Command | Description |
|---|---|
git fetch upstream | Get the latest data from the original repository without applying it locally |
git merge upstream/main | Merge the fetched changes into your local main |
git push origin main | Push the merged result to your GitHub repository |
⚠️ If a conflict occurs during
merge, fix the relevant file manually, then rungit addandgit commit.
Contribute Back to the Original Project (Pull Request)
Section titled “Contribute Back to the Original Project (Pull Request)”If you want to propose your changes to the original project, send a Pull Request.
- Push your changes to your repository
- Open the original repository on GitHub
- Click New pull request
- Explain what changed and why
- The maintainers review it and merge it if they accept it
Summary
Section titled “Summary”| Operation | Command |
|---|---|
| Fork | GitHub Fork button |
| Clone | git clone |
| Register upstream | git remote add upstream |
| Pull in upstream updates | git fetch upstream -> git merge upstream/main |
| Push to your repository | git push origin main |
Q. What is the difference between a fork and a clone?
A fork copies a repository on GitHub into your GitHub account. A clone downloads a repository to your local machine. Usually you do “fork -> clone” in that order.
Q. Can I clone without forking?
A: You can work locally after cloning, but you will not have permission to push changes to your own GitHub account unless you fork it first. If you want to manage it as your own repository, you need a fork.
Q. When should I pull upstream updates?
A: Usually before you start working, or when there is a large update in the original project. It is a good habit to run git fetch upstream regularly and check the latest state.