gpt4 book ai didi

performance - Git - 在克隆之前/之后过滤

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

我有一个庞大的存储库 - 超过 1 GB。克隆存储库需要数小时。但是,大部分大小是因为不需要在本地处理项目的数据目录。但是,我当然没有权限简单地从存储库中删除目录。

有什么方法可以在克隆存储库之前对其应用过滤器,以便我只下载我实际需要处理的文件?

最佳答案

可以在克隆存储库时应用过滤器,而不是之前。
它将使用 git clone --filter=... ,详见“What is the git clone --filter option's syntax?

例如,要克隆的最小数据量为:

#fastest clone possible:
git clone --filter=blob:none --no-checkout https://github.com/git/git
cd git
git sparse-checkout init --cone
git read-tree -mu HEAD

自 Git 2.37(2022 年第 3 季度)起,“git remote -v( man ) 现在显示 list-objects-filter 在从远程获取期间使用(如​​果可用)。

git clone --filter=blob:none "file://$(pwd)/srv.bare"
git remote -v
srv.bare (fetch) [blob:none]

这也是为什么 Git 2.38(2022 年第 3 季度)将启用“git fetch(man) 客户端以记录 trace2 output 中使用的部分克隆过滤器的原因.

参见 commit 1007557 (2022 年 7 月 26 日)作者:Jonathan Tan (jhowtan) .
(由 Junio C Hamano -- gitster -- merge 于 commit 3a4d71f,2022 年 8 月 5 日)

fetch-pack: write effective filter to trace2

Signed-off-by: Jonathan Tan

Administrators of a managed Git environment (like the one at $DAYJOB) might want to quantify the performance change of fetches with and without filters from the client's point of view, and also detect if a server does not support it.

Therefore, log the filter information being sent to the server whenever a fetch (or clone) occurs.
Note that this is not necessarily the same as what's specified on the CLI, because during a fetch, the configured filter is used whenever a filter is not specified on the CLI.

GIT_TRACE2=1 git fetch

请注意,在 Git 2.40(2023 年第一季度)之前,“git http-fetch(man)(很少使用)忘记在 trace2 输出中标识自己。

参见 commit 7abb43c (2022 年 12 月 12 日)Jonathan Tan (jhowtan) .
(由 Junio C Hamano -- gitster -- merge 于 commit c099531,2022 年 12 月 26 日)

http-fetch: invoke trace2_cmd_name()

Signed-off-by: Jonathan Tan

ee4512e (trace2: create new combined trace facility, 2019-02-22, Git v2.22.0-rc0 -- merge listed in batch #2) ("trace2: create new combined trace facility", 2019-02- 22) introduced trace2_cmd_name() and taught both the Git built-ins and some non-built-ins to use it.
However, http-fetch was not one of them (perhaps due to its low usage at the time).

Teach http-fetch to invoke this function.
After this patch, this function will be invoked right after argument parsing, just like in remote-curl.c.

关于performance - Git - 在克隆之前/之后过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14978694/

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