如何推送具有子模块的分叉存储库? [英] How to push the forked repository which has submodule?

查看:63
本文介绍了如何推送具有子模块的分叉存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个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

  • 分叉两个仓库,
  • 两者都克隆
  • 在本地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.

这篇关于如何推送具有子模块的分叉存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆