dev: Converting a forked private repo to public for netlify

OK for security reasons, you cannot just convert a forked repo that was private into a public repo. I think the reason is the original repo might have contents that you do not want out in the public domain. But, if you have made a mistake and just want to force it to be public, there is a way to do this as explained by Github Help. But it doesn’t explain how you create a new repo in the first place. Fortunately, the command line tools gh.

The main reason for doing this is that if you are using the free netlify hosting, they changed their policy so you get free automatic pushes only if it is from a public repo. For a typical startup, the website is nothing special or interesting, so as long as you copyright it, it is fine if it is a public repo. You can get a typical closed-source license from Github itself of course.

So here are the steps:

Convert from Forked Private to Public Repo

  1. First, you want to create a new repo and give it the right permissions
  2. Then you create what is called a bare repo, which downloads all the strange things that git uses to keep track of things
  3. Then you do a git lfs fetch so that all the items in Git LFS are copied down and the pointers have real data objects
  4. Finally, you do a push with a –mirror to the new repo which takes all the artifacts and you will get a clone with all the commits there.
  5. And then you also push all the git lfs objects into the new repo

So a sample set of commands are:

gh repo create --public
git clone --bare
cd old-repository.git
git lfs fetch --all
git push --mirror
git lfs push --all

Change the pointer for Netlify to a new repo

Now you can go to Netlify and then choose Deploy and Repository and manage and then you authenticate and select the public repo and it should just start to build

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect