When you fork a repository on GitHub, it maintains a connection to the original (upstream) project. While forking is useful for contributing to open-source projects or experimenting independently, you might eventually want to “unfork” the repository—especially if you plan to make it independent or turn it into a standalone project.
GitHub does not currently offer a direct “unfork” button, but there are practical workarounds to achieve the same result.
🔹 What Does “Unfork” Mean?
Unforking a repository means removing the link between your forked repository and the upstream (original) project. This is often desired when:
- You want to make the repo independent
- You forked the wrong repo by mistake
- You no longer want the forked relationship
🔧 Workaround: How to Unfork a Repository
Since GitHub doesn’t support unforking directly, the best way is to recreate the repository from scratch. Here’s how:
✅ Step 1: Clone the Forked Repository Locally
git clone https://github.com/your-username/forked-repo.git
cd forked-repo
✅ Step 2: Remove Git Remote (Optional but Clean)
To remove the upstream connection (forked origin):
git remote remove origin
✅ Step 3: Create a New Repository on GitHub
- Go to GitHub
- Click New repository
- Give it a unique name (e.g.,
my-independent-project
) - Do not initialize with README, .gitignore, or license
✅ Step 4: Add the New GitHub Repository as Remote
git remote add origin https://github.com/your-username/my-independent-project.git
✅ Step 5: Push to the New Repository
git push -u origin main
Replace
main
with your branch name if it’s different (e.g.,master
)
✅ Step 6: Delete the Forked Repository (Optional)
After successfully pushing to the new repository, you can delete the original forked one:
- Go to the forked repo on GitHub
- Click Settings > Danger Zone
- Click Delete this repository
🧠 Summary
Task | Command / Action |
---|---|
Clone forked repo | git clone ... |
Remove old remote | git remote remove origin |
Create a new GitHub repo | Via GitHub UI |
Add new remote | git remote add origin <new-URL> |
Push to new repo | git push -u origin main |
🚀 Final Thoughts
While GitHub doesn’t currently support unforking directly, creating a fresh repository from your forked project is the most effective workaround. It allows you to move forward independently while preserving your code and commit history.