Github prohibits making a private repository from a forked repository. This article explains how to create a private repository that can incorporate updates from a public repository, mimicking the behavior of a forked repository.
Bare Clone and Mirror Push
Duplicate public to private repository
- Create empty private repo
- Bare clone a public repo, and mirror push it to the private repo.
$ git clone --bare https://github.com/public_username/public_repo_name.git $ cd public_repo_name.git $ git push --mirror git@github.com:my_username/my_private_repo_name.git $ cd .. $ rm -rf public_repo_name.git
Register remote repository with public repository
$ git clone git@github.com:my_username/my_private_repo_name.git
$ cd my_private_repo_name
$ git remote add public https://github.com/public_username/public_repo_name.git
Fetching from public repo
$ git pull public master
$ git push origin master
Disable push to public repo (if needed)
$ git remote set-url --push public no_push
Leave a comment