How to fork a repository
How to fork a repository
Section titled “How to fork a repository”This guide explains how to fork a repository on GitHub, step-by-step, and clarifies how forking differs from copying a repository.
What is a fork?
Section titled “What is a fork?”A fork is a server-side copy of a repository in your own GitHub account. It preserves the commit history and connection to the original (upstream) repository so you can make changes, open pull requests, and keep your fork in sync with upstream updates.
When to fork vs copy
Section titled “When to fork vs copy”- Fork when you plan to contribute back to the original project, want an independent workspace in your GitHub account, or need to create a visible public copy with a relationship to the upstream project.
 - Copy (download/archive or clone and push to a new repo) when you want a fresh, unrelated starting point or a private copy without any connection to the original project.
 
Step-by-step: Forking a repository on GitHub (web)
Section titled “Step-by-step: Forking a repository on GitHub (web)”- 
Open the repository page on GitHub (e.g., https://github.com/owner/repo or https://github.com/BankyNarayan/Test).
 - 
Click the “Fork” button in the top-right of the repository page.
 - 
Choose your account or organization where you want the fork to live.
 - 
GitHub creates the fork under your account: https://github.com/your-username/repo
 - 
Clone your fork locally:
 - 
Add the upstream remote so you can pull future updates from the original repo:
cd repo git remote add upstream https://github.com/owner/repo.git
 - 
Work on a feature branch and commit changes:
git checkout -b feature/my-change git add . git commit -m “Describe change”
 - 
Push your branch to your fork:
git push origin feature/my-change
 - 
Create a Pull Request (PR) from your fork/branch back to the original repository via GitHub web UI.
 - 
Keep your fork up-to-date with upstream (example using main/master):
git fetch upstream git checkout main git merge upstream/main git push origin main
 
Step-by-step: Forking via GitHub CLI
Section titled “Step-by-step: Forking via GitHub CLI”- 
Authenticate the CLI if not already:
gh auth login
 - 
Fork the repo:
gh repo fork owner/repo —clone=false —remote=true
 - 
Clone your fork (if you didn’t use —clone):
gh repo clone your-username/repo
 - 
The
gh repo forkcommand can automatically add anupstreamremote and set theoriginto your fork depending on flags. 
How a fork differs from copying a repository
Section titled “How a fork differs from copying a repository”- Relationship: A fork maintains metadata linking it to the upstream repository; a simple copy does not.
 - Contribution workflow: Forks are intended to submit pull requests back to upstream. Copies are typically used when you want an unrelated starting point.
 - Visibility & discoverability: Forks show up in the network graph and indicate how many forks a project has.
 - Syncing: Forks can be kept in sync with upstream; copied repositories require manual synchronization.
 
Common follow-ups
Section titled “Common follow-ups”- Create a branch per feature/PR.
 - Rebase or merge upstream changes before opening a PR to reduce conflicts.
 - Use 
ghCLI for convenience when creating PRs and keeping remotes configured. 
This page explains forking on GitHub and why it’s different from copying; adapt instructions to your workflow (SSH vs HTTPS, branch names, protected branches).