- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每个人似乎都同意的一件事是 Git 不适用于大型二进制 blob。请记住,二进制 blob 不同于大型文本文件;您可以毫无问题地在大型文本文件上使用 Git,但 Git 无法对不可渗透的二进制文件做很多事情,除非将其视为一个大的实心黑框并按原样提交。
根据 https://opensource.com/life/16/8/how-manage-binary-blobs-git-part-7 :
One thing everyone seems to agree on is Git is not great for bigbinary blobs. Keep in mind that a binary blob is different from alarge text file; you can use Git on large text files without aproblem, but Git can't do much with an impervious binary file excepttreat it as one big solid black box and commit it as-is.
Say you have a complex 3D model for the exciting new first personpuzzle game you're making, and you save it in a binary format,resulting in a 1 gigabyte file. You git commit it once, adding agigabyte to your repository's history. Later, you give the model adifferent hair style and commit your update; Git can't tell the hairapart from the head or the rest of the model, so you've just committedanother gigabyte. Then you change the model's eye color and committhat small change: another gigabyte. That is three gigabytes for onemodel with a few minor changes made on a whim. Scale that across allthe assets in a game, and you have a serious problem.
据我了解,文本文件和二进制文件之间没有区别,Git 完整地存储每次提交的所有文件(创建校验和 blob),未更改的文件只是指向一个已经存在的 blob。如何存储和压缩所有这些 blob 是另一个问题,我不知道详细信息,但我假设如果报价中的各种 1GB 文件或多或少相同,一个好的压缩算法会解决这个问题如果它们是重复的,并且可能能够将它们全部存储在甚至不到 1GB 的空间中。这个推理应该适用于二进制文件和文本文件。
与此相反,引用继续说
Contrast that to a text file like the .obj format. One commit storeseverything, just as with the other model, but an .obj file is a seriesof lines of plain text describing the vertices of a model. If youmodify the model and save it back out to .obj, Git can read the twofiles line by line, create a diff of the changes, and process a fairlysmall commit. The more refined the model becomes, the smaller thecommits get, and it's a standard Git use case. It is a big file, butit uses a kind of overlay or sparse storage method to build a completepicture of the current state of your data.
我的理解对吗?引用不正确吗?
最佳答案
Git 会完整地存储文件,因此如果您有 2 个二进制文件且只有很小的更改,它将占用两倍的空间。观察。
% git init
Initialized empty Git repository in /tmp/x/.git/
{master #}% [/tmp/x]
{master #}% du -sh .git
100K .git
{master #}% dd if=/dev/urandom of=./test count=1 bs=10M
1+0 records in
1+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.102277 s, 103 MB/s
{master #%}% ls -sh test
10M test
{master #%}% git add test
git co%
{master #}% git commit -m "Adds test"
[master (root-commit) 0c12c32] Adds test
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test
{master}% du -sh .git
11M .git
我创建了一个 10MB 的文件并添加并提交了它。存储库现在大小为 10MB。
如果我做了一个小改动然后再做一次,
{master}% e test # This is an invocation of my editor to change a few bytes.
nil
{master}% git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: test
no changes added to commit (use "git add" and/or "git commit -a")
{master *}% git add test
{master +}% git commit -m "Updates test a little"
[master 99ed99a] Updates test a little
1 file changed, 0 insertions(+), 0 deletions(-)
{master}% du -sh .git
21M .git
这将需要 20MB。 10MB 文件的两倍。
然而,这是存储库的“loose object”格式,其中每个 blob 都是磁盘上的一个单独文件。
您可以将所有这些打包到一个 git 包文件中(这在您推送等时完成),然后看看会发生什么。
{master}% git gc
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), done.
Total 6 (delta 1), reused 0 (delta 0)
{master}% du -sh .git
11M .git
现在,它只在 packfile 中存储 blob 和 diff 一次.这不同于每个只存储差异的提交。就是将对象本身打包到一个文件中。
关于git - Git 存储文本文件和二进制文件的方式有区别吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53647783/
我时不时地输入“git”,然后想到别的东西,然后输入例如“git checkout master”。当然,这给我留下了 $ git git checkout master git: 'git' is
我做到了 git 克隆 git://foo.git 光盘富 ...编辑文件.. 现在我想重新开始。我不在乎我已经做出的任何改变,但我不想再次克隆整个巨型 foo.git,只是丢失我所有的更改。我怎
我在我的电脑上开发代码,我的计算节点很少。 为了让我的程序保持同步,我决定使用 git。以前,我以一种单向模式使用它来“下推”从 PC 到计算节点的更改。但是时不时遇到计算节点特有的小bug,现场修复
虽然它似乎什么也没做,但它没有给出任何警告或错误消息。有什么想法吗? 最佳答案 来自 Git 源的注释: /* * Read a directory tree. We currently ignor
我知道如何为这样的 HTTPS 请求提供用户名和密码: git clone https://username:password@remote 但我想知道如何像这样向 Remote 提供用户名和密码:
Git GUI、Git Bash 和 Git CMD 之间有什么区别?我是初学者,为了进行安装,我发现自己通常同时使用 git bash 和 git CMD 最佳答案 Git CMD 就像使用 git
有人能告诉我git中文件索引被删除是什么意思吗?这些文件在我的 VS Code 中标记为红色,但我仍然可以修改文件并将更改推送到将反射(reflect)这些更改的远程存储库。我认为这一切都是在我使用命
我通过 git 子树将 GLFV 库添加到项目中,但出现此警告“看起来您的 git 安装或您的 git-subtree 安装已损坏”。还描述了几个原因,为什么这可能是: 如 git --exec-pa
我有需要外部 git 项目的 repo,但我不想使用子模块,因为我想在 github 上存档所有文件,所以我认为我只是将具有 git repo 的整个目录添加到 git 但它不t 添加里面的 .git
我有需要外部 git 项目的 repo,但我不想使用子模块,因为我想在 github 上存档所有文件,所以我认为我只是将具有 git repo 的整个目录添加到 git 但它不t 添加里面的 .git
我一直在阅读一篇文章,作者在其中指示:在现有存储库中创建一个新存储库,并想知道这是否是他忽略的错误。稍后我会与他核实。 这些是我要检查的条件: 将现有目录制作成仓库的条件,并且已经 checkin 主
我确实在不同的计算机上处理相同的项目,我想知道是否有一种方法可以跟踪该 .git 文件夹,这样我就不必在所有本地文件中重新配置配置文件。 我将所有工作推送到 bitbucket。 最佳答案 不,没
这个问题在这里已经有了答案: How does git store files? (3 个答案) 关闭 9 年前。 我为我的许多项目创建了一个远程存储库,所以它是我的push 的目的地。与 git
应该如何在 git 中查看文件内容的完整历史记录? 一个文件在 git 中的历史很短,存储库通过 git-svn 同步,但在 svn 中的历史很长。 git 中的历史记录到达文件移动的位置。要查看历史
我是confused here ... 如何对修改后的文件进行git commit,以及如何对新文件进行git commit? 还有,你如何在git中单独提交文件? 最佳答案 git 提交过程分为两个
正在搜索 throw SO 来寻找答案。遇到这个似乎没有给出任何答案的旧线程。重新触发此线程,希望有人知道! 有人能告诉我 git subtree 和 git filter-branch 的区别吗?为
我想知道是否有一种方法可以避免在每个 Git 命令的开头键入单词 git。 如果有一种方法可以在打开命令提示符进入 “Git 模式” 后只使用一次 git 命令就好了。 例如: git> 之后,我们键
当您修改工作目录中的文件时,git 会告诉您使用“git add”暂存。 当您向工作目录添加新文件时,git 会告诉您使用“git add”开始跟踪。 我对这两个概念有点困惑,因为我假设跟踪文件的更改
为什么 git://有效 $ git clone git://github.com/schacon/grit.git Cloning into 'grit'... ... Checking conne
我在以下沙箱中练习 git:https://learngitbranching.js.org/?NODEMO 我在两个单独的 session 中运行了两组命令。第一组命令顺序如下: git clone
我是一名优秀的程序员,十分优秀!