-
Notifications
You must be signed in to change notification settings - Fork 18
Forking to a private repo
Here are some docs from ChatGPT that I am still testing:
Yes, you're correct that on GitHub, you cannot create a private fork from a public repository. But there's a workaround for this. You can effectively create a "manual" private fork by duplicating the repository. Here's how to do it:
-
Create a new private repository on GitHub. This will be your private "fork."
-
Clone the public repository to your local machine:
git clone https://github.com/original_owner/original_repo.git
-
Navigate into the directory that was just created (it will have the same name as the repository):
cd original_repo
-
Remove the link to the original repository:
git remote remove origin
-
Link the local repository to your new private repository:
git remote add origin https://github.com/your_username/new_repo.git
-
Push the local repository to your private repository:
git push -u origin main
You now have a copy of the public repository as a private repository on your GitHub.
When the public repository gets updates, you can merge them into your private repository by adding the public repository as a remote:
git remote add upstream https://github.com/original_owner/original_repo.git
Then, you can fetch the updates:
git fetch upstream
And merge them into your private repository:
git merge upstream/main
Or, if you want to rebase (apply your changes on top of the fetched changes):
git rebase upstream/main
Then, push your changes to your private repository:
git push origin main
That's it! This will allow you to have a private "fork" of a public repository and to merge updates from the public repository into your private one.