【问题标题】:Git clone bare repo without blobsGit克隆没有blob的裸仓库
【发布时间】:2017-05-05 01:29:57
【问题描述】:

在我的 git 存储库中,我使用一种算法根据分支名称和标签为每个提交分配一个或多个唯一的版本号。我想将此机制与另一个大型存储库一起使用,我想在不传输任何文件的情况下进行克隆。

裸克隆可以帮助我摆脱 blob 的工作副本,但它仍会从服务器下载它们。带有--depth 1 的浅层克隆会跳过大多数 blob,但也会跳过下载除一个之外的所有提交的元数据。

有没有像git fast-export --no-data 这样的东西,我可以在客户端使用它来获取包含提交元数据和文件名的图形信息,而无需先从我的服务器克隆存储库?理想情况下,我可以像通过git log|show|rev-parse|show-ref 访问任何其他(裸机、浅层)repo 一样访问元数据。

(我知道 git LFS 和 git Annex 存在,可以帮助减少一些 repos 的大小,但我不能在现有存储库上使用它们而不更改它。)

【问题讨论】:

    标签: git metadata git-clone git-plumbing git-fast-import


    【解决方案1】:

    我可以在客户端使用 git fast-export --no-data 之类的东西吗?

    否:除了git ls-remote(仅获取远程仓库负责人的元数据)之外,其他任何内容都可以获得完整的仓库历史记录。

    您需要由 Git 托管服务(如 GitHub)管理您的存储库,提供 API(如 commits API),以便在没有数据的情况下查询元数据。

    【讨论】:

      【解决方案2】:

      一段时间后的另一个想法:截至 2017 年,pack-protocol 现在允许 partial clonesthere is a --filter=blob:none available 省略所有 blob - 这在服务器端应该足够了。

      鉴于当前的服务器端实现,遗憾的是,这并不像人们希望的那样工作:

      C:\Users\phi1010>git clone https://github.com/torvalds/linux.git --filter=blob:none
      Cloning into 'linux'...
      warning: filtering not recognized by server, ignoring
      remote: Enumerating objects: 6876195, done.
      [...]
      

      Github 甚至宣布了 support of the v2 protocol and its filtering capabilities,但这不适用于 -c protocol.version=2,正如 Do GitHub and GitLab support git clone's --filter parameter? 中所述

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-08-11
        • 2020-01-20
        • 2020-08-22
        • 2013-11-25
        • 1970-01-01
        • 2015-06-12
        • 2014-02-26
        • 2017-03-30
        相关资源
        最近更新 更多