是否可以添加您修改了本地设置但您不是所有者的git子模块,因此无法推送到远程。 目前,我的存储库仅添加了指向原始子模块的链接,但没有对其进行修改。 但是我希望将包括修改内容的全部内容推送到我的远程仓库中。
到目前为止,我做了以下事情:
cd my_repo
git submodule add git@mygithost:submodulue submodule
git submodule init && git submodule update
cd submodule
<changes, hacks>
git commit -am 'modify submodule'
cd .. && git status
> On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: submodule (untracked content)
no changes added to commit (use "git add" and/or "git commit -a")
答案 0 :(得分:0)
我希望将包括我的修改在内的全部内容推送到我的远程仓库中。
您不能完全这样做,因为您不能将本地更改推送到原始子模块。但是您可以通过分叉子模块来解决此问题。
首先,将git@submodulehost:submodulue
分叉到git@mygithost:submodulue
。如果您无法直接将其派生到submodulehost
克隆并推送:创建一个新的空存储库git@mygithost:submodulue
并执行
git clone -o upstream git@submodulehost:submodulue
cd submodule
git remote add origin git@mygithost:submodulue
git push --all origin
然后使用fork作为子模块的源:
cd ../superproject/submodule
git remote set-url origin git@mygithost:submodulue
git remote add upstream git@submodulehost:submodulue
修复代码并将其推送到分叉:
git push -u origin master