Git 类似于 Hg 的 Bigfiles 扩展?

标签 git version-control mercurial mercurial-bigfiles

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

基本上我想将大型二进制文件存储在我的 git 存储库中,但我不想在克隆时获取大型二进制文件的所有版本。我只想在 checkout 包含那些大文件的特定修订版时下载大二进制文件。

最佳答案

这里有几个可供考虑的选项:

浅克隆:您可以添加 --depth <depth>参数 git clone获取存储库的浅克隆。例如如果<depth>为 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.

事实上,正如this thread中所讨论的那样这是一种夸大其词的说法 - 在某些有用的情况下,从浅层克隆推送仍然有效,并且可能适合您的工作流程。

Scott Chacon 的“git media”扩展:作者在对 this similar question 的回答中对此进行了描述在 github 上的自述文件中:http://github.com/schacon/git-media .

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

还有很多方法可以通过添加钩子(Hook)来实现这一点(例如)从 git 钩子(Hook)中对你的大文件进行 rsync,但我认为你有充分的理由希望将这些文件保持在 git 的控制之下第一名。

希望对您有所帮助。

关于Git 类似于 Hg 的 Bigfiles 扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3161588/

相关文章:

git - 如果本地存在分支,我应该在 pull 之前执行 git fetch 吗?

intellij-idea - 在 hg 中使用 intellij idea merge 作为默认 merge 工具

git - 版本控制建议

java - 通过 bash 和 Java 的 ProcessBuilder api 运行相同的命令会得到不同的输出

git - 如何使用 github webhooks 阻止特定的推送?

mercurial - 在 Cruisecontrol.net 中更改 DVCS 的操作流程?

mercurial - 我可以自行托管类似于Bitbucket的软件

git - Intellij IDEA项目中如何从Git索引中删除文件?

git - 带有 "named commits"的 DVCS

git - 创建 git 分支,并将原始状态恢复为上游状态