There is another option. Keep a private fork for a public repository if you want to add new “secret” functionality or some credentials.
Summary
Do a bare clone of the public repo.
Create a new private one.
Do a mirror push to the new private one.
Steps:
-
Create a new empty private repository via Github.
-
Clone the public repository that we want to base our private repository on:
``` git clone --bare https://github.com/foo/public-repository.git ```
-
Move into the cloned repository and execute a push with the
--mirror
flag:cd public-repository git push --mirror https://github.com/foo/private-repository.git
The
--mirror
flag push ensures that all the branches and tags that are available in the public repository are replicated in the new location. -
The public repository that we cloned in step 2 can now be deleted:
cd .. rm -rf public-repository
-
In order to work on the private repository, we just need to clone it:
$ git clone https://github.com/foo/private-repository.git $ cd private-repository