简体   繁体   English

使用哪组命令来创建公共 github 回购的私有分支

[英]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?这两种方法有什么区别?

  1. git remote add + a normal git push git remote add +一个普通的git push
  2. 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".我认为这意味着“将管理文件与工作树混合”,这看起来很奇怪,但现在我明白它的意思是“只克隆管理文件,而不是工作树”。

Git remote add | Git 远程添加 | git push git 推送

Pushes only the main branch in this case.在这种情况下只推送主分支。

Git push --mirror Git 推送 --mirror

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.

相关问题 如何将公共仓库的分支设为私有并与 github.com 上的原始仓库进行比较 - How to make a fork of a public repo private and compare to original repo on github.com 分叉GitHub存储库并制作私有的Bitbucket存储库,并在私有Pod中使用cocoapods - Fork GitHub repo and make private bitbucket repo, and use cocoapods with private pod GitHub:如何将公共存储库的分支设为私有? - GitHub: How to make a fork of public repository private? 将私有 github 存储库中的目录设为公开 - Make directory in private github repo public Github - TA 要求我们公开我们的私人回购。 我和另一个一样分叉了私人回购。 分叉状态在公开后被移除 - Github - TA asked us to make our private repos public. I forked private repo as did another. The fork status was removed after being made public 如果我将其他人的私有 Github 存储库分叉到我的帐户中,它会作为公共存储库出现在我的帐户中吗? - If I fork someone else's private Github repo into my account, is it going to appear in my account as a public repo? 为 github 创建一个公共 git repo 的分支 - Create a fork of public git repo for github 是否可以将公共 GitHub 存储库分叉到企业存储库中? - Is it possible to fork a public GitHub repo into an enterprise repository? Github-将私人回购克隆到公共回购 - Github- Cloning a private repo to a public repo 从私人GitHub回购转向公共和私人 - Moving from Private GitHub Repo to Public and Private
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM