且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何推送具有子模块的分叉存储库?

更新时间:2022-06-15 04:06:14

是的,子模块本身就是git repo.
您需要

Yes, a submodule is a git repo in itself.
You need to

  • 分叉两个仓库,
  • 两者都克隆
  • 在本地AS之间建立符号链接(仅用于代码编译,即,不必在本地干扰S的子模块状态)
  • 在两个本地仓库中提交您的更改,并将其推送到各自的分支中
  • 发出两个请求(一个用于A,一个用于S)
  • fork both repo,
  • clone them both,
  • make a symlink between A and S locally (just for your code to compile, ie don't bother with the submodule status of S locally)
  • commit in both local repo your changes and push them to your respective fork
  • make two pull requests (one for A, one for S)

只有AS的维护者可以:

  • S中应用拉取请求并提交
  • A
  • 中应用拉取请求
  • A中提交,记录S(子模块)的新SHA1和A中的更改.
  • apply your pull request in S and commit
  • apply your pull request in A
  • commit in A, recording the new SHA1 of S (submodule) and the changes in A.

Mark Longair 提到您可以:

  • 克隆A
  • 的叉子
  • git submodule init
  • git submodule update(它将克隆S到右侧的SHA1,但是将'S'作为远程对象,而不是'forked-S')
  • cd S
  • git remote set-url origin <SSH-url-of-fork-of-S>
  • git checkout -b my-changes-to-S:创建一个分支以记录您的本地修改,并避免进入
  • clone your fork of A
  • git submodule init
  • git submodule update (that will clone S to the right SHA1, but with 'S' as a remote, not 'forked-S')
  • cd S
  • git remote set-url origin <SSH-url-of-fork-of-S>
  • git checkout -b my-changes-to-S: make a branch in order to record your local modification, and to avoid being in a detached HEAD mode.