Git 类似于 Hg 的 Bigfiles 扩展?
我想要 git 中类似于 Mercurial 的 Bigfiles Extension 的东西(注意:我知道 git-bigfiles,但这是不相关的)。
基本上我想在我的 git 存储库中存储大型二进制文件,但我不想在进行克隆时获得大型二进制文件的每个版本。我只想在签出包含这些大文件的特定修订版时下载大型二进制文件。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是一些需要考虑的选项:
浅克隆:您可以将
--深度 <深度>
参数添加到git clone
中以获取存储库的浅克隆。例如,如果<深度>
为 1,这意味着克隆将仅获取最近提交所需的文件。但是,此类存储库对您可以使用它们执行的操作有一些尴尬的限制,如git clone
手册页中所述:事实上,如 这个线程有点夸张 - 在某些情况下从浅层推送是有用的克隆仍然可以工作,并且可能适合您的工作流程。
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 togit 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 thegit clone
man page: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.