gpt4 book ai didi

git - 使用不同子模块设置的 checkout 提交无法正常工作

转载 作者:太空狗 更新时间:2023-10-29 14:26:00 24 4
gpt4 key购买 nike

在我们的一个 git 仓库中,在某个时候添加了一个子模块。现在,每当我检查 git repo 的状态时,子模块还不存在,它没有正确地“删除”子模块。它似乎处于子模块一半存在,一半不存在的状态。

我还注意到,子模块不再预设在 .gitmodules 中,而是它的文件夹在 path/to/submodule.git/modules 仍然存在。

我至少尝试了以下事情:

git status => 未跟踪的文件:path/to/submodule

git reset --hard => 不变

git submodule foreach reset --hard => 不变

git clean -d -f => 跳过存储库路径/to/submodule

git submodule update --init => 不变

但是直到现在我都没有解决。当然,我可以手动删除这些文件夹,但我希望它在我切换提交时自动运行,因为这也是我们 CI (Jenkins) 上的一个问题。

非常感谢任何帮助/提示!

最佳答案

您需要使用双 -f 参数运行 git clean。来自documentation (强调我的):

-f --force

If the Git configuration variable clean.requireForce is not set to false, git clean will refuse to delete files or directories unless given -f, -n or -i. Git will refuse to delete directories with .git sub directory or file unless a second -f is given. This affects also git submodules where the storage area of the removed submodule under .git/modules/ is not removed until -f is given twice.

所以正确的命令是:git clean -d -f -f

关于git - 使用不同子模块设置的 checkout 提交无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32881972/

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