我将把这些捆绑文件作为另一台机器上的备份
自从我 2011 年的回答(十一年前)以来,你现在拥有像这样的远程管道GitHub 操作 https://github.com/features/actions or 亚搏体育appGitLab持续集成 https://docs.gitlab.com/ee/ci/.
这些远程 Git 存储库托管服务上的自动化管道可以为您创建捆绑包并将其保存到服务器/备份。
那就是今天。
明天,您将能够“git 捆绑包“-专用服务器,可通过捆绑包 URI.
在 Git 2.38(2022 年第 3 季度)中,“bundle URI”设计被记录下来。
See commit d06ed85 https://github.com/git/git/commit/d06ed85dcbfa3eaf083a5fa5324670d049117bea, commit 2da14fa https://github.com/git/git/commit/2da14fad8fe9889f067da2abe3b0763acae1f8f9 (09 Aug 2022) by Derrick Stolee (derrickstolee) https://github.com/derrickstolee.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 0d133a3 https://github.com/git/git/commit/0d133a3dcf43eb0396a5899008a4ff4ceaeb0d6e, 18 Aug 2022)
docs https://github.com/git/git/commit/2da14fad8fe9889f067da2abe3b0763acae1f8f9:文档包 URI 标准
Signed-off-by: Derrick Stolee
通过理想的设计文档将捆绑 URI 的想法引入 Git 代码库。
本文档包含完整的设计,旨在以完全实现的形式包含该功能。
这将采取实施计划部分详细介绍的几个步骤。
通过现在提交此文档,它可以用来激励实现这些最终目标所需的更改。
随着新信息的发现,设计仍然可以改变。
technical/bundle-uri
现在包含在其man page https://github.com/git/git/blob/2da14fad8fe9889f067da2abe3b0763acae1f8f9/Documentation/technical/bundle-uri.txt#L1-L468:
捆绑 URI
Git 包是存储包文件以及一些额外元数据的文件,
包括一组引用和一组(可能为空)必要的提交。看git bundle https://git-scm.com/docs/git-bundle和链接:bundle-format.txt[捆绑格式]了解更多信息
信息。
捆绑包 URI 是 Git 可以下载一个或多个捆绑包的位置
为了在获取剩余的数据之前引导对象数据库
来自远程的对象。
目标之一是加快网络状况较差的用户的克隆和获取速度
与源服务器的连接。另一个好处是允许重度用户,
例如 CI 构建农场,将本地资源用于大部分 Git 数据
从而减轻源服务器的负载。
要启用捆绑包 URI 功能,用户可以使用以下命令指定捆绑包 URI
命令行选项或源服务器可以通告一个或多个 URI
通过协议 v2 功能。
See Also
And:
bundle-uri https://github.com/git/git/commit/d06ed85dcbfa3eaf083a5fa5324670d049117bea:添加示例包组织
Signed-off-by: Derrick Stolee
添加一个部分,详细说明捆绑包提供程序如何工作,包括对多个地理分布式服务器使用 Git 服务器广告。
该组织基于 GVFS 缓存服务器,该服务器已成功地使用类似的想法为非常大的存储库提供快速对象访问并减少服务器负载。
technical/bundle-uri
现在包含在其man page https://github.com/git/git/blob/d06ed85dcbfa3eaf083a5fa5324670d049117bea/Documentation/technical/bundle-uri.txt#L352-L456:
捆绑包提供商组织示例
此示例组织是所使用内容的简化模型
GVFS 缓存服务器(请参阅本文档末尾附近的部分)
有利于加速非常大的克隆和获取
存储库,尽管使用 Git 之外的额外软件。
捆绑包提供商跨多个地理位置部署服务器。
每个服务器管理自己的捆绑包集。
服务器可以跟踪多个 Git 存储库,但根据模式为每个存储库提供捆绑列表。
例如,当镜像存储库时https://<domain>/<org>/<repo>
捆绑包服务器可以在以下位置获取其捆绑包列表:https://<server-url>/<domain>/<org>/<repo>
.
源Git服务器可以
在“任意”模式下列出所有这些服务器:
[bundle]
version = 1
mode = any
[bundle "eastus"]
uri = https://eastus.example.com/<domain>/<org>/<repo>
[bundle "europe"]
uri = https://europe.example.com/<domain>/<org>/<repo>
[bundle "apac"]
uri = https://apac.example.com/<domain>/<org>/<repo>
这个“列表的列表”是静态的,并且仅当捆绑服务器处于活动状态时才会改变。
添加或删除。
捆绑包服务器定期运行捆绑包列表更新,
比如每天一次。
在此任务期间,服务器会获取最新的
来自原始服务器的内容并生成包含以下内容的包
可从最新的原始引用访问的对象,但不包含在
先前计算的包。
此捆绑包已添加到列表中,请小心
认为creationToken
严格大于先前的最大值creationToken
.
这里提供了一个示例捆绑列表,尽管它每天只有两个
捆绑包,而非 30 个完整列表:
[bundle]
version = 1
mode = all
heuristic = creationToken
[bundle "2022-02-13-1644770820-daily"]
uri = https://eastus.example.com/<domain>/<org>/<repo>/2022-02-09-1644770820-daily.bundle
creationToken = 1644770820
[bundle "2022-02-09-1644442601-daily"]
uri = https://eastus.example.com/<domain>/<org>/<repo>/2022-02-09-1644442601-daily.bundle
creationToken = 1644442601
[bundle "2022-02-02-1643842562"]
uri = https://eastus.example.com/<domain>/<org>/<repo>/2022-02-02-1643842562.bundle
creationToken = 1643842562
这种数据组织的意图有两个主要目标。
-
一、初始
通过下载预先计算的对象,存储库的克隆变得更快
来自更近的来源的数据。
-
Second, git fetch
命令可以更快,
特别是如果客户已经好几天没有取货了。然而,如果一个
客户端在 30 天内没有获取数据,那么捆绑列表组织将
导致重新下载大量对象数据。
This is implemented (still with Git 2.38 (Q3 2022)): "git clone --bundle-uri https://github.com/git/git/blob/68ef0425d99cafb08f4c33eaa558505068fe2143/Documentation/git-clone.txt"(man https://git-scm.com/docs/git-clone).
See commit 65da938 https://github.com/git/git/commit/65da93891680edc0d1471d436d92d4da7d0b4465 (23 Aug 2022), and commit e21e663 https://github.com/git/git/commit/e21e663cd1942df29979d3e01f7eacb532727bb7, commit 59c1752 https://github.com/git/git/commit/59c1752ab6768cb9c380f0a7c9d06af79d183f67, commit 5556891 https://github.com/git/git/commit/55568919616429fbc209880cf189a3adaceb6093, commit 53a5089 https://github.com/git/git/commit/53a50892be20a91fb0dcf572a641ce2a79af1a38, commit b5624a4 https://github.com/git/git/commit/b5624a44744d6e5f9c749e4df02932c724e2097e (09 Aug 2022) by Derrick Stolee (derrickstolee) https://github.com/derrickstolee.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 68ef042 https://github.com/git/git/commit/68ef0425d99cafb08f4c33eaa558505068fe2143, 01 Sep 2022)
clone https://github.com/git/git/commit/55568919616429fbc209880cf189a3adaceb6093: 添加 --bundle-uri 选项
Reviewed-by: Josh Steadmon
Signed-off-by: Derrick Stolee
克隆远程存储库是 Git 中最昂贵的操作之一。
服务器可能会花费大量的 CPU 时间来为客户端的请求生成包文件。
数据量大会导致网络长时间堵塞,而且Git协议不可恢复。
对于网络连接较差或距离源服务器较远的用户来说,这可能尤其痛苦。
Add a new '--bundle-uri
' option to 'git clone https://github.com/git/git/blob/55568919616429fbc209880cf189a3adaceb6093/Documentation/git-clone.txt'(man https://git-scm.com/docs/git-clone) to bootstrap a clone from a bundle.
If the user is aware of a bundle server, then they can tell Git to bootstrap the new repository with these bundles before fetching the remaining objects from the origin server.
git clone
现在包含在其man page https://github.com/git/git/blob/55568919616429fbc209880cf189a3adaceb6093/Documentation/git-clone.txt#L326-L331:
--bundle-uri=<uri>
在从远程获取之前,从给定的位置获取包<uri>
并将数据解绑到本地存储库中。
裁判们
捆绑包中将存储在隐藏下refs/bundle/*
命名空间。
此选项不兼容--depth
, --shallow-since
, and --shallow-exclude
Git 2.39(2022 年第 4 季度)定义了“bundle list
”、将它们存储在核心中的数据结构、传输它们的格式以及解析它们的代码。
See commit 8628a84 https://github.com/git/git/commit/8628a842bddda7723ad7548b7f6d141123a164a0, commit 70334fc https://github.com/git/git/commit/70334fc3ebf1c6199014d82bbbf0595b64a8fa90, commit 89bd7fe https://github.com/git/git/commit/89bd7fedf947484da08e2722d663fdac23a431be, commit c23f592 https://github.com/git/git/commit/c23f592117bac30765ca22545386c3e9304da803, commit c96060b https://github.com/git/git/commit/c96060b0cef79c9d76eb97965e700beb9651f35b, commit 20c1e2a https://github.com/git/git/commit/20c1e2a68bfcb85dd919c92a82c129cee215c23a, commit 738e524 https://github.com/git/git/commit/738e5245fa423fc43495e2e17e053365dc6b2fc0, commit bff03c4 https://github.com/git/git/commit/bff03c47f7342c2a08fac6c0af7229b1579fea15, commit 0634f71 https://github.com/git/git/commit/0634f717a3e3c57ee5d965882366df1ada1ad11b, commit 23b6d00 https://github.com/git/git/commit/23b6d00ba7fd4b3446319395cfe3791710e81d92 (12 Oct 2022) by Derrick Stolee (derrickstolee) https://github.com/derrickstolee.
See commit d796ced https://github.com/git/git/commit/d796cedbe8ca77310a7dabcafe60b040aa0e2b67, commit 9424e37 https://github.com/git/git/commit/9424e373fd2136aa7f5cec23c8cafc272996ecd6 (12 Oct 2022) by Ævar Arnfjörð Bjarmason (avar) https://github.com/avar.
See commit f677f62 https://github.com/git/git/commit/f677f62970eed0f4b1a9075bcaf3f9f64027f30e (24 Aug 2022) by Junio C Hamano (gitster) https://github.com/gitster.
(Merged by Taylor Blau -- ttaylorr -- https://github.com/ttaylorr in commit d32dd8a https://github.com/git/git/commit/d32dd8add53120cef9b30be4240010c2ab6bfc6f, 30 Oct 2022)
bundle-uri https://github.com/git/git/commit/c23f592117bac30765ca22545386c3e9304da803:获取捆绑包列表
Signed-off-by: Derrick Stolee
当给定捆绑包 URI 中的内容不被理解为捆绑包(基于检查初始内容)时,Git 目前会放弃并忽略该内容。
独立的捆绑包提供商可能希望将捆绑包内容拆分为多个捆绑包,但仍可通过单个 URI 获取它们。
教 Git 尝试将包 URI 内容解析为 Git 配置文件,提供key=value
对作为捆绑列表。
然后,Git 查看列表的模式,看看是否有任何单个包就足够了,或者是否需要所有包。
下载所选 URI 处的内容并再次检查内容,从而创建递归过程。
为了防止递归出现格式错误或恶意内容,暂时将递归深度限制为合理的四。
如果需要,可以在将来将其转换为配置值。
四的值是预期有用的两倍(捆绑列表不太可能指向更多捆绑列表)。
要测试此场景,请创建一个有趣的捆绑包拓扑,其中三个增量捆绑包构建在单个完整捆绑包之上。
通过使用合并提交,两个中间捆绑包是“独立的”,因为它们不需要彼此来解绑自己。
他们每个人只需要基础包。
不过,包含合并提交的包需要两个中间包。
这会导致在分拆时做出一些有趣的决定,特别是当我们稍后实施启发式方法来促进下载捆绑包直到满足先决条件提交时。
Git 2.40(2023 年第 1 季度)继续实施捆绑 URI(第 4 部分)。
See commit 876094a https://github.com/git/git/commit/876094ac16870727207e6afc0b26060101a52359, commit 12b0a14 https://github.com/git/git/commit/12b0a14b9e5f140a9a4d5a3e3c47fae00a53c6fc, commit ebc3947 https://github.com/git/git/commit/ebc39479558fb4893c72a35065e6792515acef86, commit 9ea5796 https://github.com/git/git/commit/9ea57964953dec11dcbbd5d4bf44a5e3781f5880, commit 738dc7d https://github.com/git/git/commit/738dc7d4a5f42376bc748008dd8792aa4eb25627, commit 1b759e0 https://github.com/git/git/commit/1b759e0cf1c18c637e40c6c191a0b614e4e4ea43 (22 Dec 2022) by Derrick Stolee (derrickstolee) https://github.com/derrickstolee.
See commit 70b9c10 https://github.com/git/git/commit/70b9c1037325ee82bc0832f4ca2d30c6ebf4808e, commit 7cce907 https://github.com/git/git/commit/7cce9074a728fb32501054577963d8ae31d007be, commit 0cfde74 https://github.com/git/git/commit/0cfde740f0b2c9474aae3a381d1d6e97c7468e7a, commit 8f788eb https://github.com/git/git/commit/8f788eb8b75502acb5c7d771279e486bae626dde, commit 8b8d9a2 https://github.com/git/git/commit/8b8d9a229888adb737851c4d7eeaa9a50e37afe1 (22 Dec 2022) by Ævar Arnfjörð Bjarmason (avar) https://github.com/avar.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 0903d8b https://github.com/git/git/commit/0903d8bbdef6c2607f2e0bf43a4d10cf54b03744, 02 Jan 2023)
bundle-uri client https://github.com/git/git/commit/7cce9074a728fb32501054577963d8ae31d007be:添加布尔值transfer.bundleURI
setting
Co-authored-by: Derrick Stolee
Signed-off-by: Ævar Arnfjörð Bjarmason
Signed-off-by: Derrick Stolee
尚未引入的对bundle-uri 的客户端支持将始终依赖于完整克隆,但我们仍然希望能够完全忽略服务器的bundle-uri 广告。
The new transfer.bundleURI
配置选项默认为“false”,但用户可以将其设置为“true”以启用使用协议 v2 检查来自源 Git 服务器的捆绑包 URI。
git config
现在包含在其man page https://github.com/git/git/blob/7cce9074a728fb32501054577963d8ae31d007be/Documentation/config/transfer.txt#L118-L123:
transfer.bundleURI
When true
, local git clone
命令将请求捆绑包
来自远程服务器的信息(如果公布)并下载
包,然后通过 Git 协议继续克隆。
默认为false
.
And:
bundle-uri https://github.com/git/git/commit/738dc7d4a5f42376bc748008dd8792aa4eb25627: serve bundle.* keys
从配置
Signed-off-by: Derrick Stolee
通过填充来实现“bundle-uri”协议 v2 功能key=value
来自本地 Git 配置的数据包行。
捆绑包列表由以“bundle.”开头的键提供。
And:
bundle-uri https://github.com/git/git/commit/ebc39479558fb4893c72a35065e6792515acef86: 允许捆绑列表中的相对 URL
Signed-off-by: Derrick Stolee
捆绑包提供商可能希望跨多个 CDN 分发该数据。
这可能需要更改基本 URI,一直到域名。
如果所有包都需要在其 'uri
' 值,那么每次推送到 CDN 都需要更改目录以匹配预期的域和其中的确切位置。
允许捆绑包列表指定捆绑包的相对 URI.
此 URI 基于客户端接收捆绑列表的位置。
对于“bundle-uri”协议 v2 命令中提供的列表,Git 远程 URI 是基本 URI。
否则,捆绑包列表是从不使用 Git 协议的 HTTP URI 提供的,并且该 URI 是基本 URI。
这使得捆绑数据的分发更加容易。
在 Git 2.40(2023 年第一季度)中,bundle-URI 子系统添加了对创建令牌启发式的支持,以帮助增量获取。
See commit 026df9e https://github.com/git/git/commit/026df9e04789e2af7271566f312aae323740309f, commit c429bed https://github.com/git/git/commit/c429bed10223135a13f1f2f854e367762c37af7a, commit 7f0cc04 https://github.com/git/git/commit/7f0cc04f2ca1653d573dbe981090895dc959ce65, commit 0524ad3 https://github.com/git/git/commit/0524ad3542c48c759366bc49dbd8bed4cc94dc79, commit 4074d3c https://github.com/git/git/commit/4074d3c7e1a3b44c5c02235799d798f8b2613333, commit 7903efb https://github.com/git/git/commit/7903efb7170ca9704e80ef9188bef37ecf55f2d6, commit 512fccf https://github.com/git/git/commit/512fccf8a503bd8617fe46cb62c77480b83fbaea, commit c93c3d2 https://github.com/git/git/commit/c93c3d2fa42bec64948441cb339d78e2044ff9a3, commit 7bc73e7 https://github.com/git/git/commit/7bc73e7b61e60cbc0730a4f0e938c482c459e000, commit d9fd674 https://github.com/git/git/commit/d9fd674c8b26c376b37e02d974b92033acb99732, commit e72171f https://github.com/git/git/commit/e72171f085e48ed9292809815bf70b6e685b73c6 (31 Jan 2023) by Derrick Stolee (derrickstolee) https://github.com/derrickstolee.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 4f59836 https://github.com/git/git/commit/4f598364519f5bb871caf12a482ed117a270588b, 15 Feb 2023)
clone https://github.com/git/git/commit/4074d3c7e1a3b44c5c02235799d798f8b2613333:如果合适的话设置 fetch.bundleURI
Signed-off-by: Derrick Stolee
捆绑包提供商可能会以旨在改进增量获取(而不仅仅是初始克隆)的方式组织其捆绑包列表。
然而,他们确实需要声明他们已经考虑到这一点进行组织,否则客户将不会期望通过在初始克隆后下载捆绑包来节省时间。
这是通过指定bundle.heuristic 值来完成的。
有两种类型的捆绑列表:静态 URI 上的捆绑列表和通过协议 v2 从 Git 远程发布的捆绑列表。
The new fetch.bundleURI config value applies for static bundle URIs that are not advertised over protocol v2.
If the user specifies a static URI via 'git clone --bundle-uri https://github.com/git/git/blob/4074d3c7e1a3b44c5c02235799d798f8b2613333/Documentation/git-clone.txt#L326'(man https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---bundle-urilturigt), then Git can set this config as a reminder for future 'git fetch https://github.com/git/git/blob/4074d3c7e1a3b44c5c02235799d798f8b2613333/Documentation/git-fetch.txt'(man https://git-scm.com/docs/git-fetch) operations to check the bundle list before connecting to the remote(s).
对于通过协议 v2 提供的列表,我们将希望采取不同的方法并通过创建remote.<id>.*
键入配置键。
在此更改中并未实现这一点。
稍后更改将更新'git fetch
' 使用此选项。
git config
现在包含在其man page https://github.com/git/git/blob/4074d3c7e1a3b44c5c02235799d798f8b2613333/Documentation/config/fetch.txt#L99-L106:
fetch.bundleURI
该值存储用于从包下载 Git 对象数据的 URI
从源 Git 服务器执行增量获取之前的 URI。
这类似于--bundle-uri
选项的行为在git clone https://git-scm.com/docs/git-clone.
git clone --bundle-uri
将设置fetch.bundleURI
如果提供的捆绑包 URI 包含捆绑包,则该值
为增量获取而组织的列表。
"git fetch --all https://github.com/git/git/blob/89833fc249189d5b91509b1b3f16b26aade9e7f7/Documentation/git-fetch.txt"(man https://git-scm.com/docs/git-fetch) does not have to download and handle the same bundleURI over and over, which has been corrected with Git 2.41 (Q2 2023).
See commit 25bccb4 https://github.com/git/git/commit/25bccb4b79dce1d5c259228ef3c91eadcd13d8ac (31 Mar 2023) by Derrick Stolee (derrickstolee) https://github.com/derrickstolee.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 89833fc https://github.com/git/git/commit/89833fc249189d5b91509b1b3f16b26aade9e7f7, 06 Apr 2023)
fetch https://github.com/git/git/commit/25bccb4b79dce1d5c259228ef3c91eadcd13d8ac:下载一次捆绑包,即使使用--all
Signed-off-by: Derrick Stolee
When fetch.bundleURI
is set, 'git fetch https://github.com/git/git/blob/25bccb4b79dce1d5c259228ef3c91eadcd13d8ac/Documentation/git-fetch.txt'(man https://git-scm.com/docs/git-fetch) downloads bundles from the given bundle URI before fetching from the specified remote.
However, when using non-file remotes, 'git fetch --all
' will launch 'git fetch
' subprocesses which then read fetch.bundleURI
and fetch the bundle list again.
We do not expect the bundle list to have new information during these multiple runs, so avoid these extra calls by un-setting fetch.bundleURI in the subprocess arguments.
请小心跳过获取空捆绑字符串的捆绑。
从空列表中获取包会出现一些有趣的测试失败。