gpt4 book ai didi

git submodule 检查同一个提交

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

在我 git submodule update 之后,它总是检查同一个提交。例如 34561

我为子模块执行 git checkout master,然后执行 git submodule sync。然后它指向最新的提交 a2344

但是在更新之后它再次指向提交34561

如何改变呢?我的意思是为什么它决定指向那个提交而不是另一个?

最佳答案

I mean why it decided to point to that commit and not another?

因为子模块总是在父仓库中将固定的 SHA1 提交记录为 gitlink ( special entry in the index )。
这就是为什么子模块总是被恢复为 detached HEAD branch 的原因。

你可以配置一个子模块跟随一个分支

cd /path/to/your/parent/repo
git config -f .gitmodules submodule.<path>.branch <branch>

子模块仍将恢复到固定提交,但随后可以更新为:

git submodule update --remote

确保在父仓库中添加并提交新的 gitlink(因为将子模块更新到分支的最新版本会更改其 SHA1,在父仓库中记录为 gitlink)。< br/>如果不这样做,您将在接下来的 git submodule update --init 中发现您的子模块恢复到之前的状态。

在“Git submodules: Specify a branch/tag”中查看更多信息。

关于git submodule 检查同一个提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30343488/

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