如何推送具有子模块的分叉存储库? [英] How to push the forked repository which has submodule?
问题描述
有一个A
项目,而A项目有一个子模块S
A
| -S
| -B
| -C
There is a A
project and the A project has a submodule S
A
|-S
|-B
|-C
回购:git@github.com:本杰明/ A .git
仓库:git@github.com:所有者/ S .git
A repo: git@github.com:benjamin/A.git
S repo: git@github.com:owner/S.git
要提供一些错误修复,我分叉了A
存储库并对其进行了克隆.
To contribute some bug fix, I forked the A
repository and cloned it.
$ git clone git@github.com:benjamin/A.git
然后下载我命令的submodule S
$ git submodule init
$ git submodule update
好的,代码树做得很好,我将错误修复为A
中的文件和S
中的文件.
要提交并推送这两个文件,
Okay, the code tree are made well, and I fixed the bug at a file in A
and a file in S
.
To commit and push the two files,
$ cd S
$ git add modified_file
$ git commit -a -m 'submodule commit'
$ git push
但是推不起作用.
错误:所有者/S.git的权限被本杰明拒绝.
致命:远端意外挂起
ERROR: Permission to owner/S.git denied to benjamin.
fatal: The remote end hung up unexpectedly
我也应该分叉S
存储库吗?在这种情况下,您该怎么办?
Should I also fork S
repository either? How do you do in this case?
推荐答案
是的,子模块本身就是git repo.
您需要
Yes, a submodule is a git repo in itself.
You need to
- 分叉两个仓库,
- 两者都克隆
- 在本地
A
和S
之间建立符号链接(仅用于代码编译,即,不必在本地干扰S
的子模块状态) - 在两个本地仓库中提交您的更改,并将其推送到各自的分支中
- 发出两个请求(一个用于
A
,一个用于S
)
- fork both repo,
- clone them both,
- make a symlink between
A
andS
locally (just for your code to compile, ie don't bother with the submodule status ofS
locally) - commit in both local repo your changes and push them to your respective fork
- make two pull requests (one for
A
, one forS
)
只有A
和S
的维护者可以:
- 在
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 ofS
(submodule) and the changes inA
.
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 cloneS
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 detachedHEAD
mode.
这篇关于如何推送具有子模块的分叉存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!