Git 类似于 Hg 的 Bigfiles 扩展?

发布于 2024-09-08 02:13:45 字数 345 浏览 3 评论 0 原文

我想要 git 中类似于 Mercurial 的 Bigfiles Extension 的东西(注意:我知道 git-bigfiles,但这是不相关的)。

基本上我想在我的 git 存储库中存储大型二进制文件,但我不想在进行克隆时获得大型二进制文件的每个版本。我只想在签出包含这些大文件的特定修订版时下载大型二进制文件。

I want something in git that is similar to Mercurial's Bigfiles Extension (note: I know of git-bigfiles, but that is unrelated).

Basically I want to store large binaries in my git repository, but I don't want to get every version ever of the large binary when I do a clone. I only want to download the large binaries when I checkout a specific revision containing those large files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤还要旧人安 2024-09-15 02:13:45

以下是一些需要考虑的选项:

浅克隆:您可以将 --深度 <深度> 参数添加到 git clone 中以获取存储库的浅克隆。例如,如果 <深度> 为 1,这意味着克隆将仅获取最近提交所需的文件。但是,此类存储库对您可以使用它们执行的操作有一些尴尬的限制,如 git clone 手册页中所述:

        --depth 
           Create a shallow clone with a history truncated to the specified
           number of revisions. A shallow repository has a number of
           limitations (you cannot clone or fetch from it, nor push from nor
           into it), but is adequate if you are only interested in the recent
           history of a large project with a long history, and would want to
           send in fixes as patches.

事实上,如 这个线程有点夸张 - 在某些情况下从浅层推送是有用的克隆仍然可以工作,并且可能适合您的工作流程。

Scott Chacon 的“git media”扩展:作者在回答 这个类似的问题以及github上的自述文件:http://github.com/schacon/git-media

浅层子模块:您可以将所有大文件保存在单独的 git 存储库中,并将其添加为 浅子模块到您的主存储库。这样做的优点是您的代码不受浅克隆的限制,只有包含大文件的存储库。

还有很多方法可以通过添加钩子(例如)从 git 钩子对大文件进行 rsync 来实现此目的,但我认为您有充分的理由希望首先将这些文件置于 git 的控制之下。

我希望这有一些帮助。

Here are a few options to consider:

Shallow clones: You can add the --depth <depth> parameter to git clone to get a shallow clone of the repository. e.g. if <depth> is 1, this means that the clone will only fetch the files needed for the most recent commit. However, such repositories have awkward restrictions on what you can do with them, as outlined in the git clone man page:

        --depth 
           Create a shallow clone with a history truncated to the specified
           number of revisions. A shallow repository has a number of
           limitations (you cannot clone or fetch from it, nor push from nor
           into it), but is adequate if you are only interested in the recent
           history of a large project with a long history, and would want to
           send in fixes as patches.

In fact, as discussed in this thread that's something of an overstatement - there are useful situations where pushing from a shallow clone will still work, and it's possible that will fit your workflow.

Scott Chacon's "git media" extension: the author describes this in answer to this similar question and in the README on github: http://github.com/schacon/git-media .

Shallow submodules: you could keep all your large files in a separate git repository and add that as a shallow submodule to your main repository. This would have the advantage that you don't have the restrictions of shallow clones for your code, just the repository with the large files.

There also are any number of ways of doing this by adding hooks that (for example) rsync over your large files in from git hooks, but I assume that there are good reasons that you want to keep these files under git's control in the first place.

I hope that's of some help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文