简体   繁体   English

捆绑 git 存储库而不克隆它

[英]Bundle git repository without cloning it

How can I bundle a git project without cloning it every time?如何捆绑 git 项目而不每次都克隆它? Right now I do always commands below.现在我总是在下面命令。

git clone --mirror http://git_project
cd git_project
git bundle create '../git_project.lock' --all
cd ..
rm git_project -Force -Recurse

I want to do this in one command, something like:我想在一个命令中执行此操作,例如:

git bundle create '../git_project.lock' --all --repository http://git_project

I'll to got these bundle files as a backup on an other machine我将把这些捆绑文件作为备份放在另一台机器上

Since my 2011 answer (eleven years ago), you now have remote pipelines like GitHub Actions or GitLab CI .自我 2011 年的回答(11 年前)以来,您现在拥有远程管道,例如GitHub ActionsGitLab CI

An automated pipeline on those remote Git repository hosting services can create a bundle for you and save it to a server/backup.这些远程 Git 存储库托管服务上的自动化管道可以为您创建一个捆绑包并将其保存到服务器/备份。

That is today.就是今天。


Tomorrow, you will be able to a " git bundle "-dedicated server, accessible through a bundle URI .明天,您将能够使用“ git 捆绑包”-专用服务器,可通过捆绑包 URI访问。

With Git 2.38 (Q3 2022), the "bundle URI" design gets documented.使用 Git 2.38(2022 年第三季度),“捆绑 URI”设计得到了记录。

See commit d06ed85 , commit 2da14fa (09 Aug 2022) by Derrick Stolee ( derrickstolee ) .请参阅Derrick Stolee ( derrickstolee ) 的commit d06ed85commit 2da14fa (2022 年 8 月 9 日)。
(Merged by Junio C Hamano -- gitster -- in commit 0d133a3 , 18 Aug 2022) (由Junio C Hamano -- gitster --提交 0d133a3中合并,2022 年 8 月 18 日)

docs : document bundle URI standard docs : 文档包 URI 标准

Signed-off-by: Derrick Stolee签字人:Derrick Stolee

Introduce the idea of bundle URIs to the Git codebase through an aspirational design document.通过理想的设计文档将捆绑 URI 的概念引入 Git 代码库。
This document includes the full design intended to include the feature in its fully-implemented form.本文档包含完整的设计,旨在以完全实现的形式包含该功能。
This will take several steps as detailed in the Implementation Plan section.这将采取实施计划部分中详述的几个步骤。

By committing this document now, it can be used to motivate changes necessary to reach these final goals.通过现在提交此文档,它可用于激发实现这些最终目标所需的更改。
The design can still be altered as new information is discovered.随着新信息的发现,设计仍然可以更改。

technical/bundle-uri now includes in its man page : technical/bundle-uri现在包含在其手册页中:

Bundle URIs捆绑 URI

Git bundles are files that store a pack-file along with some extra metadata, including a set of refs and a (possibly empty) set of necessary commits. Git 包是存储包文件以及一些额外元数据的文件,包括一组参考和一组(可能为空的)必要提交。 See git bundle and link:bundle-format.txt[the bundle format] for more information.有关详细信息,请参阅git bundle和链接:bundle-format.txt[捆绑包格式]。

Bundle URIs are locations where Git can download one or more bundles in order to bootstrap the object database in advance of fetching the remaining objects from a remote.捆绑 URI 是 Git 可以下载一个或多个捆绑的位置,以便在从远程获取剩余对象之前引导 object 数据库。

One goal is to speed up clones and fetches for users with poor network connectivity to the origin server.一个目标是为与原始服务器的网络连接较差的用户加快克隆和获取速度。 Another benefit is to allow heavy users, such as CI build farms, to use local resources for the majority of Git data and thereby reducing the load on the origin server.另一个好处是允许重度用户(例如 CI 构建农场)将本地资源用于大部分 Git 数据,从而减少源服务器上的负载。

To enable the bundle URI feature, users can specify a bundle URI using command-line options or the origin server can advertise one or more URIs via a protocol v2 capability.要启用捆绑 URI 功能,用户可以使用命令行选项指定捆绑 URI,或者源服务器可以通过协议 v2 功能通告一个或多个 URI。

See Also也可以看看

And:和:

bundle-uri : add example bundle organization bundle-uri :添加示例包组织

Signed-off-by: Derrick Stolee签字人:Derrick Stolee

Add a section that details how a bundle provider could work, including using the Git server advertisement for multiple geo-distributed servers.添加一个详细说明捆绑提供程序如何工作的部分,包括为多个地理分布式服务器使用 Git 服务器广告。
This organization is based on the GVFS Cache Servers which have successfully used similar ideas to provide fast object access and reduced server load for very large repositories.该组织基于 GVFS 缓存服务器,它们已成功使用类似的想法来提供快速 object 访问并减少非常大的存储库的服务器负载。

technical/bundle-uri now includes in its man page : technical/bundle-uri现在包含在其手册页中:

Example Bundle Provider organization示例 Bundle Provider 组织

This example organization is a simplified model of what is used by the GVFS Cache Servers (see section near the end of this document) which have been beneficial in speeding up clones and fetches for very large repositories, although using extra software outside of Git.此示例组织是 GVFS 缓存服务器使用的简化 model(请参阅本文档末尾附近的部分),尽管使用了 Git 之外的额外软件,但它有助于加速非常大的存储库的克隆和获取。

The bundle provider deploys servers across multiple geographies.捆绑供应商在多个地区部署服务器。
Each server manages its own bundle set.每台服务器都管理自己的捆绑包集。

The server can track a number of Git repositories, but provides a bundle list for each based on a pattern.服务器可以跟踪许多 Git 存储库,但会根据模式为每个存储库提供捆绑列表。

For example, when mirroring a repository at https://<domain>/<org>/<repo> the bundle server could have its bundle list available at https://<server-url>/<domain>/<org>/<repo> .例如,当在https://<domain>/<org>/<repo>镜像存储库时,捆绑服务器可以在https://<server-url>/<domain>/<org>/<repo>获得其捆绑列表https://<server-url>/<domain>/<org>/<repo>
The origin Git server can list all of these servers under the "any" mode: origin Git 服务器可以在“any”模式下列出所有这些服务器:

 [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>

This "list of lists" is static and only changes if a bundle server is added or removed.此“列表列表”为 static,仅在添加或删除捆绑服务器时才会更改。

The bundle server runs regularly-scheduled updates for the bundle list, such as once a day.捆绑服务器为捆绑列表运行定期更新,例如每天一次。
During this task, the server fetches the latest contents from the origin server and generates a bundle containing the objects reachable from the latest origin refs, but not contained in a previously-computed bundle.在此任务期间,服务器从源服务器获取最新内容并生成一个包,其中包含可从最新源 refs 访问的对象,但不包含在先前计算的包中。
This bundle is added to the list, with care that the creationToken is strictly greater than the previous maximum creationToken .将此捆绑包添加到列表中,注意creationToken严格大于先前的最大creationToken

An example bundle list is provided here, although it only has two daily bundles and not a full list of 30:此处提供了一个示例捆绑包列表,尽管它只有两个每日捆绑包,而不是 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

The intention of this data organization has two main goals.这种数据组织的意图有两个主要目标。

  • First, initial clones of the repository become faster by downloading precomputed object data from a closer source.首先,通过从更接近的来源下载预先计算的 object 数据,存储库的初始克隆变得更快。

  • Second, git fetch commands can be faster, especially if the client has not fetched for a few days.其次, git fetch命令可以更快,特别是如果客户端几天没有获取。 However, if a client does not fetch for 30 days, then the bundle list organization would cause redownloading a large amount of object data.但是,如果客户端 30 天未获取,则捆绑列表组织会导致重新下载大量 object 数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM