Home > Mobile >  Which set of commands to use to make private fork of public github repo
Which set of commands to use to make private fork of public github repo

Time:02-18

I'm trying to fork a public github repo but keep the fork private on my end. I've found steps for doing that here: https://gist.github.com/0xjac/85097472043b697ab57ba1b1c7530274 (and other places, but the instructions are similar)

So after doing steps 1 & 2, step 3 is to push the content to the new repo via this command:

git push --mirror [email protected]:<your_username>/<repo_name>.git

Meanwhile, the new github repo shows the standard tips, which include this:

...or push an existing repository from the command line:

git remote add origin [email protected]:<your_username>/<repo_name>.git
git branch -M main
git push -u origin main

What is the difference between these 2 approaches?

  1. git remote add a normal git push
  2. git push --mirror all by itself

Git remotes & refs kind of make my head spin. In general, I understand approach #1 and am inclined to do that but I'm not sure if it's appropriate here. Approach #2 is the recommendation but I don't understand the description of the mirror option in the man page.

CodePudding user response:

Git remote add | git push

Pushes only the main branch in this case.

Git push --mirror

Pushes all branches, tags and commits and creates a true mirror of the repository in your private fork.

  • Related