gpt4 book ai didi

git - "--remote"实际上在 "git submodule update --remote"中做了什么?

转载 作者:行者123 更新时间:2023-12-03 20:17:30 26 4
gpt4 key购买 nike

我只是不明白 Git 的帮助页面。那么会发生什么或有什么区别?

假设我有一个带有子模块 B 的 Git 项目 A。子模块 B 确实有一个子模块 C。克隆存储库后,A 指向 B 的特定提交。B 指向 C 的特定提交。

如果我在 A 里面,我会通过

cd B

现在我输入
git submodule update --remote

或者
git submodule update

有什么不同?假设远程服务器确实有A、B、C的变化。

我猜想使用“git submodule update --remote”会保留对特定 C 版本的引用。是否在没有 --remote 的情况下使用它?更新到最新版本的 C?

最佳答案

假设 B 是 A 的唯一子模块。

cd A
git ls-tree -r HEAD | grep commit

输出类似于
160000 commit 0814c6ba8f45829f04709c56118868d2483444c2 foo foo是子模块文件夹和 0814c6ba8f45829f04709c56118868d2483444c2是 A 的当前提交跟踪的修订版本。
git submodule update做类似的事情
cd B
git checkout 0814c6ba8f45829f04709c56118868d2483444c2
git submodule update --remote就好像
cd B
git fetch origin master
git checkout origin/master

默认 masterorigin/master被使用。如果分支由 submodule.foo.branch = bar 指定在 .gitmodule ,然后 barorigin/bar被使用。

关于git - "--remote"实际上在 "git submodule update --remote"中做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47470271/

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