Cal*_*eng 15 git git-submodules
假设以下项目布局: -
mainrepo_git
|____ .git
|____ .gitmodules
|____ proj <------- directory containing the code files for mainrepo
|____ 3rdpartysourcecode <-- directory containing upstream open source code
| |____ .git
| |____ 3rdpartyfiles
|
|____ mainrepofilesanddirectories
Run Code Online (Sandbox Code Playgroud)
mainrepo_git包含我直接负责的源代码.我有读/写访问权限,可以直接推送到我管理的远程git存储库.
嵌套在mainrepo_git中的是一个名为3rdpartysourcecode的目录.这个3rdpartysourcecode目录实际上是另一个git repo(通常也称为"git submodule"),它指向由其他开发人员管理的开源第三方git存储库.我只有读取权限.没有写访问权限.
有没有办法'冻结'git子模块的特定提交哈希与我的主存储库中提交的相关?
例如,如果我在(或我恢复)在我的mainrepo中提交a12ucak,我的git子模块也会被恢复为特定版本,我将其绑定为提交a12ucak?当我切换到提交b349jdsak时,我的git子模块也会恢复到我绑定到b349jdsak的版本?
所以我的问题是:有一种方法可以在主仓库中的特定提交与git子模块中的相应提交之间创建链接吗?以这种方式,当我在主git repo中检出特定提交时,git子模块中的相应提交也将是checkout.
Kar*_*ldt 11
冻结是子模块的重点.你应该真正阅读它的教程.简而言之,git add 3rdpartysourcecode
(重要的没有尾部斜杠!)后面的提交将当前检出的子模块提交锁定到超级模块提交.然后你git submodule update
用来检查那个修订版.