gpt4 book ai didi

git - "git submodule absorbgitdirs"的对面/反面?

转载 作者:太空狗 更新时间:2023-10-29 13:00:57 35 4
gpt4 key购买 nike

我怎样才能做 git submodule absorbgitdirs 的反向操作? ? IE。移动子模块的 .git信息出superproject/.git/modules/<module>然后回到 superproject/path/to/<module>/.git目录?

我还想要<module>成为 superproject 的子模块,我只是不想<module>.git superproject 中的目录信息的 .git/modules目录。

最佳答案

请注意,这将使 superproject/path/to/<module>/ 嵌套 Git 存储库,其 SHA1 仍将由父项目记录。

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

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

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

I still want to be a submodule of superprojec

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

submodule absorbgitdirs 不留任何选择:

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 the core.worktree and adding a .git file pointing to the git directory embedded in the superprojects git directory.

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

absorbgitdirs介绍于 commit f6f8586适用于 Git 2.12(2016 年第 4 季度)
Its tests shows它希望使用 GIT_DIR/modules .

较旧的 Git(before Git 1.7.8,2011 年 10 月)有一个 .git直接在子模块文件夹中。


Jeremiah Rose 所述在 the comments :

Another use case is: if you are using a Docker container to use git commands inside a submodule, where the container can't see the superproject and errors out. :(

关于git - "git submodule absorbgitdirs"的对面/反面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44559306/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com