- Published on
How to create a private fork of a public repo on GitHub?
- Authors
- Name
- Saad Bash
- Clone the public bare repo locally:
git clone --bare git@github.com:Username/cool-public-repo.git
cd cool-public-repo.git
- Push newly cloned public repo to your own Private GitHub repo:
git push --mirror git@github.com:saadjs/private-repo.git
- Delete the old clone
cd ..
rm -rf cool-public-repo.git
- Clone the private repo to work on locally:
git clone git@github.com:saadjs/private-repo.git && cd $_
Optional:
To pull new changes made to the original public repo:
git remote add public git@github.com:Username/cool-public-repo.git
Create a new branch to pull the changes
git checkout -b new-changes-from-public git pull public main git push --set-upstream origin new-changes-from-public # or merge into to main & push to origin main