[英]Fork public repository into private and receive public commits
让我们拥有公共 github 存储库 (A) https://github.com/schacon/example
我想将此存储库分叉到 bitbucket 作为私有存储库 (B)。
我想接收从存储库 A 到存储库 B 的公开提交。
是否可以?
B
的新私有存储库。 在本地克隆B
转到存储库B
。 使用 GitHub 存储库 (repo A) 的 URL 添加一个新的远程(比如 repoA)。
$ git remote add repoA <A-repo-url> $ git remote -v # see the remotes
将 A 存储库的提交/更改拉入存储库 B。
$ git pull repoA master # B's master = A's origin/master
将更改推送到存储库 B (BitBucket)。
$ git push origin HEAD # B's origin/master = A's origin/master
获取存储库 A 的所有分支。
$ git fetch repoA
使用 A 分支的历史创建一个新分支(比如next
)
$ git checkout -b next repoA/next # create a local 'next' branch = repoA/next
将本地next
分支更改推送到存储库 B 的next
分支。
$ git push origin next
将来,与存储库 A 保持同步。
$ git fetch repoA
现在将 A 的分支拉入 B 的分支,或者像上面的例子一样结帐到一个新的分支。 然后推送到 B 的仓库。
注意repoA
是您的存储库 A 的 URL,而origin
是存储库 B 的 URL。
有几种方法可以做到这一点:
对于镜像副本(例如所有分支),其在 github 文档中的介绍非常清楚: https : //help.github.com/articles/duplicating-a-repository/ 。 但是,请注意,这些方法严格用于镜像存储库,即它们创建不适合进行本地开发工作的裸本地存储库。
简而言之:
A. 对于一次性镜像副本:
$ git clone --bare https://github.com/exampleuser/A.git
$ cd A.git
$ git push --mirror https://github.com/exampleuser/B.git
$ cd ..
$ \rm -rf A.git
B. 对于正在进行的镜像副本:
设置 - 首先创建目标 Bitbucket 存储库,然后在本地创建
$ git clone --mirror https://github.com/exampleuser/A.git
$ cd A.git
$ git remote set-url --push origin https://bitbucket.com/exampleuser/B.git
然后根据需要,从 A 拉取更改并将它们推送到 B
$ cd A.git
$ git fetch -p origin
$ git push --mirror
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.