[英]Branching in a git repo with submodules
Say I create a git repo with a submodule in it.假设我创建了一个 git 存储库,其中包含一个子模块。 Then I clone the repo (with the submodule) and create a branch in my local repo.
然后我克隆存储库(带有子模块)并在我的本地存储库中创建一个分支。 Will that branch include the submodule?
该分支会包含子模块吗? If I change 2 files in the repo, f1 an f2, with f1 in the submodule and f2 outside of the submodule, and then commit my change, will that commit include both files?
如果我在 repo 中更改了 2 个文件,f1 和 f2,f1 在子模块中,f2 在子模块之外,然后提交我的更改,该提交会包括这两个文件吗? If I then push the commit, will that change the remote submodule?
如果我然后推送提交,那会改变远程子模块吗?
cd SubmoduleRepo
git commit --all -m "Change submodule code" // commit changes directly to submodule repo
git push submodule_origin // push changes to remote submodule repo
cd .. // go back to main repository working folder
git add SubmoduleRepo // commit that submodule repo was changed
git commit -m "Updated submodule"
git push origin // push changes for the main repo
Yes it will include the submodule but it will not commit f1 to the submodule's repo.是的,它将包含子模块,但不会将 f1 提交到子模块的存储库。
Think of submodule as a subrepo.将子模块视为子存储库。 It is a separate repository REFERENCED in your current repo.
它是您当前存储库中引用的单独存储库。 Imagine that many team/repo is referencing/using that repository via submodule too.
想象一下,许多团队/repo 也通过子模块引用/使用该存储库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.