[英]Which set of commands to use to make private fork of public github repo
I'm trying to fork a public github repo but keep the fork private on my end.我正在尝试分叉一个公共 github 回购协议,但在我这边将分叉保密。 I've found steps for doing that here: https://gist.github.com/0xjac/85097472043b697ab57ba1b1c7530274 (and other places, but the instructions are similar)
我在这里找到了执行此操作的步骤: https://gist.github.com/0xjac/85097472043b697ab57ba1b1c7530274 (和其他地方,但说明类似)
So after doing steps 1 & 2, step 3 is to push the content to the new repo via this command:所以在完成第 1 步和第 2 步之后,第 3 步是通过此命令将内容推送到新的 repo:
git push --mirror git@github.com:<your_username>/<repo_name>.git
Meanwhile, the new github repo shows the standard tips, which include this:同时,新的 github 存储库显示了标准提示,其中包括:
...or push an existing repository from the command line:
git remote add origin git@github.com:<your_username>/<repo_name>.git
git branch -M main
git push -u origin main
What is the difference between these 2 approaches?这两种方法有什么区别?
git remote add
+ a normal git push
git remote add
+一个普通的git push
git push --mirror
all by itself git push --mirror
all by itself Git remotes & refs kind of make my head spin. Git 遥控器和参考让我头晕目眩。 In general, I understand approach #1 and am inclined to do that but I'm not sure if it's appropriate here.
总的来说,我理解方法 #1 并倾向于这样做,但我不确定它在这里是否合适。 Approach #2 is the recommendation but I don't understand the description of the
mirror
option in the man
page.方法 #2 是推荐方法,但我不理解
man
页中mirror
选项的描述。
Edit: In retrospect, I totally misunderstood the --bare
option from step 1, which would have helped me understand the --mirror
option later on.编辑:回想起来,我完全误解了步骤 1 中的
--bare
选项,这会帮助我稍后理解--mirror
选项。 The --bare
option says: --bare
选项说:
Make a bare Git repository.
制作一个裸 Git 存储库。 That is, instead of creating <directory> and placing the administrative files in <directory>/.git, make the <directory> itself the $GIT_DIR.
也就是说,不是创建 <directory> 并将管理文件放在 <directory>/.git 中,而是使 <directory> 本身成为 $GIT_DIR。
This is not clearly written, IMO. IMO,这没有写清楚。 I thought this meant "mix the administrative files in with the working tree", which seemed strange, but now I see it means "only clone administrative files, not the working tree".
我认为这意味着“将管理文件与工作树混合”,这看起来很奇怪,但现在我明白它的意思是“只克隆管理文件,而不是工作树”。
Pushes only the main branch in this case.在这种情况下只推送主分支。
Pushes all branches, tags and commits and creates a true mirror of the repository in your private fork.推送所有分支、标签和提交,并在您的私有分支中创建存储库的真实镜像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.