与"git子模块吸收gitdirs"相反/相反? [英] Opposite/reverse of "git submodule absorbgitdirs"?
问题描述
如何执行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
我仍然想成为superprojec的子模块
I still want to be a submodule of superprojec
然后将其.git
文件夹放在superproject/.git/modules/<module>
子模块absorbgitdirs
没有任何选择:
submodule absorbgitdirs
does not leave any choice:
如果子模块的git目录位于子模块内部,请将子模块的git目录移动到其超级项目
$GIT_DIR/modules
路径中,然后通过设置core.worktree
,并添加一个指向超级项目git目录中嵌入的git目录的.git
文件.
If a git directory of a submodule is inside the submodule, move the git directory of the submodule into its superprojects
$GIT_DIR/modules
path and then connect the git directory and its working directory by setting thecore.worktree
and adding a.git
file pointing to the git directory embedded in the superprojects git directory.
我在 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"相反/相反?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!