gpt4 book ai didi

git子模块更新 "no-fetch"

转载 作者:行者123 更新时间:2023-12-03 16:28:35 25 4
gpt4 key购买 nike

当我发布子模块更新并像这样包含“--no-fetch”时:

git submodule update --remote --no-fetch

documentation状态:

In order to ensure a current tracking branch state, update --remote fetches the submodule’s remote repository before calculating the SHA-1. If you don’t want to fetch, you should use submodule update --remote --no-fetch.



我对“--no-fetch”部分有点困惑。如果我在没有它的情况下调用更新:
git submodule update --remote

我知道不会执行提取 - 但这也意味着我不能保证“当前跟踪分支状态”?这到底是什么意思呢?

在什么情况下我不想保证当前的跟踪分支状态?

最佳答案

git submodule update在引擎盖下做了几件事。来自 git help submodule :

Update the registered submodules to match what the superprojectexpects by cloning missing submodules, fetching missing commits insubmodules and updating the working tree of the submodules.


所以运行 git submodule update --remote大致相当于(在子模块内):
$ git fetch origin  # update remote-tracking branches
$ git checkout origin/HEAD # update working tree
origin/HEAD是一个跟踪远程存储库分支的远程跟踪分支(它通常是 stash 的,但您可以通过 git branch --remotes 看到它)。请注意 git fetch引发网络事件,但 git checkout完全在本地发生。 --no-fetch跳过第一步,但仍会将您的子模块工作树更新到远程跟踪分支。
我不认为您更喜欢 --no-fetch 的常见情况。 ,但它可能在连接受限的情况下最有用。例如,在你上飞机之前,你可以 git fetch --recurse-submodules .然后在飞行期间您可以使用 git submodule update --remote --no-fetch (更新到子模块远程跟踪分支)或 git submodule update --no-fetch (更新到 super 项目中记录的提交)无需访问网络。但是,这不会有“当前跟踪分支状态”,因为您的远程跟踪分支只会与您上次获取的时间一样新。

关于git子模块更新 "no-fetch",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29244398/

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