git子模块吸收gitdirs

git子模块吸收gitdirs

本文介绍了与"git子模块吸收gitdirs"相反/相反?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何执行git submodule absorbgitdirs的相反操作? IE.将子模块的.git信息移出superproject/.git/modules/<module>并返回到superproject/path/to/<module>/.git目录?

How can I do the reverse of git submodule absorbgitdirs? I.e. move a submodule's .git information out of superproject/.git/modules/<module> and back to the superproject/path/to/<module>/.git directory?

我仍然希望<module>superproject的子模块,我只是不希望superproject.git/modules目录中的<module>.git目录信息.

I still want <module> to be a submodule of superproject, I just don't want <module>'s .git directory info in superproject's .git/modules directory.

推荐答案

请注意,这将使superproject/path/to//成为嵌套的Git存储库,其SHA1仍将由父项目记录.

Note that this would make superproject/path/to// a nested Git repo, whose SHA1 would still be recorded by the parent project.

要保持完全相同的状态,可以复制superproject/.git/modules/<module>并重命名为superproject/path/to/<module>,然后将<module>/<module>重命名为<module>/.git.

To keep the exact same state, you can copy superproject/.git/modules/<module> and rename to superproject/path/to/<module>, and rename <module>/<module> to <module>/.git.

然后,您可以使用 git submodule deinit 删除子模块:

Then you can use the git submodule deinit to remove the submodule:

mv asubmodule asubmodule_tmp
git submodule deinit -f -- a/submodule
rm -rf .git/modules/a/submodule

# if you want to leave it in your working tree
git rm --cached asubmodule
mv asubmodule_tmp asubmodule


然后将其.git文件夹放在superproject/.git/modules/<module>

子模块absorbgitdirs 没有任何选择:

submodule absorbgitdirs does not leave any choice:

我在 git config 中看不到任何可能移动的配置$GIT_DI R/modules.

absorbgitdirs提交f6f8586 的Git 2.12中引入(2016年第四季度)
它的测试表明它希望使用GIT_DIR/modules.

absorbgitdirs was introduced in commit f6f8586 for Git 2.12 (Q4 2016)
Its tests shows it expects to use GIT_DIR/modules.

旧版Git(在Git之前1.7.8 ,2011年10月)在子模块文件夹中直接有一个.git.

Older Git (before Git 1.7.8, Oct. 2011) had a .git directly inside the submodule folder.

这篇关于与"git子模块吸收gitdirs"相反/相反?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:37