Search code examples
gitgithubforkclone

Copying a GitHub Blog Page repository rather than forking it


I have setup a Github Blog Page. I want to create another copy of it (with a separate Github login), but keep it private. If I create the 2nd Page by forking, then Github doesn't allow me to change the visibility of my repository to private saying Private Visibility for forked repositories is not allowed.

Is there an easy way I can create my new private repository by copy the original repository rather than my forking it.


Solution

  • I think there are a couple of ways to go about this. One option I believe that will work here is to designate the main repo as a GitHub template (Check out the Settings for the GitHub repo), and then create a private repo using that template (there should be a green button that says "Use this template"). This is the easiest way, but the issue here is this is a one-time copy and changes to your blog won't be reflected in the private repo.

    The other option would be to push your Github Blog page to an empty private repo on the another account. Here you would:

    1. Create an empty (no commits) private repo with the new login and give your primary account (the one with the blog) write access (so you can push to it)
    2. Within your local of your github blog, you would then set-up a git remote with git remote add private <GitHub private repo URL.git>
    3. You would then do a git push git push private and those contents will be included in the private repo.

    This is something that I do for multiple git hosting services (e.g., GitHub, Overleaf, BitBuck). I wrote this blog post some time ago that demonstrated this with two different hosting services. In this case, I had copies in different private repositories, both accessible from the same local copy of the repository.