将 public 存储库分叉为私有并接收 public 提交
Fork public repository into private and receive public commits
让我们拥有 public github 存储库 (A) https://github.com/schacon/example
我想将此存储库 fork 到 bitbucket 作为私有存储库 (B)。
我想接收 public 从存储库 A 到存储库 B 的提交。
可以吗?
- 在 BitBucket 中创建一个名为
B
的新私有存储库。在本地克隆 B
。
转到存储库 B
。使用 GitHub 存储库(repo A)的 URL 添加一个新的远程(例如,repoA)。
$ git remote add repoA <A-repo-url>
$ git remote -v # see the remotes
将A仓库的commits/changes拉入仓库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 的分支,或者像上面的示例一样结帐到一个新分支。然后Push到B的仓库。
注意 repoA
是你的仓库 A 的 URL 和 origin
是仓库 B 的 URL 这里。
有几种方法可以做到这一点:
- 只是严格镜像一个 repo - 不要尝试在本地副本中进行开发工作
- 在本地工作区进行开发工作,同时 pushing/pulling 作为工作流程的一部分使用 2 个不同的遥控器。
对于镜像副本(例如所有分支),在此处的 github 文档中非常清楚地涵盖了它:https://help.github.com/articles/duplicating-a-repository/。但是,请注意,这些方法严格用于镜像存储库,即它们创建不适合进行本地开发工作的裸本地存储库。
简而言之:
一个。对于一次性镜像副本:
$ 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
乙。对于正在进行的镜像复制:
设置 - 首先创建目标 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
让我们拥有 public github 存储库 (A) https://github.com/schacon/example
我想将此存储库 fork 到 bitbucket 作为私有存储库 (B)。
我想接收 public 从存储库 A 到存储库 B 的提交。
可以吗?
- 在 BitBucket 中创建一个名为
B
的新私有存储库。在本地克隆B
。 转到存储库
B
。使用 GitHub 存储库(repo A)的 URL 添加一个新的远程(例如,repoA)。$ git remote add repoA <A-repo-url> $ git remote -v # see the remotes
将A仓库的commits/changes拉入仓库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 的分支,或者像上面的示例一样结帐到一个新分支。然后Push到B的仓库。
注意 repoA
是你的仓库 A 的 URL 和 origin
是仓库 B 的 URL 这里。
有几种方法可以做到这一点:
- 只是严格镜像一个 repo - 不要尝试在本地副本中进行开发工作
- 在本地工作区进行开发工作,同时 pushing/pulling 作为工作流程的一部分使用 2 个不同的遥控器。
对于镜像副本(例如所有分支),在此处的 github 文档中非常清楚地涵盖了它:https://help.github.com/articles/duplicating-a-repository/。但是,请注意,这些方法严格用于镜像存储库,即它们创建不适合进行本地开发工作的裸本地存储库。
简而言之:
一个。对于一次性镜像副本:
$ 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
乙。对于正在进行的镜像复制:
设置 - 首先创建目标 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