gpt4 book ai didi

git submodule init 没有 pull 最新的提交

转载 作者:IT王子 更新时间:2023-10-29 01:07:07 26 4
gpt4 key购买 nike

我有一个 git 仓库,里面有一个 git 子模块。子模块托管在 bitbucket 上。我想将子模块的本地副本更新为最新提交。我厌倦了“git submodule update”,但它什么也没做。所以我尝试删除子模块文件夹,然后执行“git submodule init”,但它只是提取初始子模块提交,而不是最新提交。

如何让我的本地子模块更新到最新的提交?

最佳答案

Git 正在做它应该做的事情。 git submodule update 会将您的子模块设置为父仓库中当前提交指定的子模块应该位于的位置。通过这种方式,您可以 check out 另一个分支、旧的提交或标记,然后运行 ​​git submodule update,子模块将被设置为该引用所期望的,这样您的整个解决方案就会满足它的依赖性。

你需要做的是:

cd mysubmoduledir
git fetch
git checkout master # or any other branch that you need the latest of
git merge origin/master
cd - # go back to the top repo
git status # should show that your submodule changed
git add mysubmoduledir
git commit -m "Updated my solution to use latest sub project."

一个较短的版本是:

cd mysubmoduledir
git pull # assumes you are already on the branch you need to be on
cd -
git commit -am "Updated submodule" # assumes you had no other modified files

“更新”这个词对于这个子模块命令来说不是最好的。它的真正意思是“将子模块指向父仓库的提交所期望的提交”。

将子模块更新为不同的提交(不必是最新的)需要您进入该目录,像普通的 git 仓库一样操作它,以便当前提交是您想要的,然后返回并提交此更改在顶级 repo 协议(protocol)中。

关于git submodule init 没有 pull 最新的提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13844996/

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