How to Unfork a Repository in GitHub

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

  1. Go to GitHub
  2. Click New repository
  3. Give it a unique name (e.g., my-independent-project)
  4. 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:

  1. Go to the forked repo on GitHub
  2. Click Settings > Danger Zone
  3. Click Delete this repository

🧠 Summary

TaskCommand / Action
Clone forked repogit clone ...
Remove old remotegit remote remove origin
Create a new GitHub repoVia GitHub UI
Add new remotegit remote add origin <new-URL>
Push to new repogit 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.

Sharing Is Caring:

Leave a Comment