GitHub
repository
forking
privacy
tutorial

GitHub How to make a fork of public repository private?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

On GitHub, you generally cannot take a public fork and simply flip it into a private fork. Current GitHub guidance is that fork visibility is constrained by the fork network, so the practical solution is usually to create a separate private repository that duplicates the code instead of keeping it as a fork.

Why a Public Fork Cannot Just Become Private

Forks are part of a repository network that preserves upstream relationships. That network behavior is why GitHub documents visibility limits on forks and treats visibility changes differently from ordinary repositories.

So if the question is "how do I make my existing public fork private without changing its identity", the answer is usually: you cannot do that directly on GitHub.com for a normal public fork.

The Usual Workaround: Duplicate the Repository

If what you actually need is:

  • a private copy of the code
  • your own commit history going forward
  • no public visibility

then create a new private repository and push the code into it as an ordinary repository, not as a fork.

Mirror the Repository Into a New Private Repo

One clean way is a mirror clone followed by a push to a newly created private repository:

bash
git clone --bare https://github.com/upstream-owner/project.git
cd project.git
git push --mirror [email protected]:your-user/private-project.git

This copies branches, tags, and refs into your private repository. After that, you can remove the temporary bare clone:

bash
cd ..
rm -rf project.git

Now your-user/private-project is a standalone private repository, not a fork.

A Working Copy Version

If you already have a normal local clone and just want to publish it privately:

bash
1git remote -v
2git remote rename origin upstream
3git remote add origin [email protected]:your-user/private-project.git
4git push -u origin main

This keeps a convenient upstream remote pointing at the public source while your origin points at the new private repo.

That setup is useful when you still want to pull updates from the public source:

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

What You Lose by Not Keeping It as a Fork

A duplicated private repository is not part of the original fork network. That means:

  • GitHub no longer shows it as a fork on the repository page
  • pull requests are not tied to fork metadata automatically
  • upstream network graphs and fork relationships are gone

For many teams that is acceptable. The important part is deciding whether you need privacy more than you need fork-network features.

Alternative: Change the Original Repository Visibility

GitHub does allow ordinary repositories to change visibility in many cases, but making a public root repository private has consequences. Current GitHub documentation notes that public forks remain public and become detached. That matters if you control the original repository, but it does not help when your repository is already only a public fork of someone else's project.

Licensing Still Applies

Making your copy private does not erase the original repository's license. If the public project is under an open-source license, you still need to comply with that license in your private copy. Privacy changes visibility, not license obligations.

Common Pitfalls

The biggest mistake is assuming GitHub treats a fork exactly like any other repository for visibility changes. Fork network rules make the behavior different.

Another common issue is creating a private duplicate but forgetting to preserve an upstream remote, which makes later sync work awkward. Developers also sometimes think a private duplicate will still behave like a GitHub fork for pull request workflows. It will not. Finally, do not ignore licensing just because the new repository is private.

Summary

  • You usually cannot directly make a public fork into a private fork on GitHub.
  • The common workaround is to create a separate private repository and push the code there.
  • Use git clone --bare plus git push --mirror for a full copy of refs and tags.
  • Keep an upstream remote if you still want to pull changes from the public source.
  • A private duplicate is not the same thing as a GitHub fork and will not keep fork-network features.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.