git - .gitattributes 文件中的 "*.jpg binary -delta"有什么作用?

标签 git github git-push git-commit gitattributes

This thread建议放置

*.jpg binary -delta

在用于 git repo 的 .gitattribute 文件中,但我不确定它的作用。我找不到 git 的“-delta”标志的任何示例。

目的是明显加快较大文件的提交或推送时间。

最佳答案

这可能与:

包装元素

delta

Delta compression will not be attempted for blobs for paths with the attribute delta set to false.

我在“Is the git binary diff algorithm (delta storage) standardized?”中详细介绍了增量存储。

默认情况下二进制文件没有设置,因为:

our originally intended target audience are people who use git as a source code control system.

Jeff King adds :

I delta jpgs in one of my repositories. It is useful if the exif metadata changes but the image data does not. I assume you could do the same with other formats which have compressed and uncompressed portions (I also do it with video containers). I don't think it would ever make sense to try to delta gzip'd or bzip'd contents.

I also don't use "binary", as I use a custom diff driver instead (binary implies "-diff").

As for what should be the default, until now the default has always been that no gitattributes are defined by default. This is nice because it's simple to understand; git doesn't care about filenames unless you tell it to.
The downside obviously is that it may not perform optimally for some unusual workloads without extra configuration.

.gitattributes man page提及:

The simplest way to mark a file as binary is to unset the diff attribute in the .gitattributes file:

*.ps -diff

This will cause Git to generate Binary files differ (or a binary patch, if binary patches are enabled) instead of a regular diff.

所以,是的“设置“binary”属性也会取消设置“text”和“diff”属性,但是Jeff 说在他的案例中只使用了 -diff,这足以让文件成为二进制文件。

关于git - .gitattributes 文件中的 "*.jpg binary -delta"有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24978611/

相关文章:

git - 用原始仓库中的内容强制覆盖本地文件?

git - 是否有内置的 Git 工具可以将单个文件复制到所有分支?

Python git 模块无效的 git 存储库错误

android - leandroBorgesFerreira/LoadingButtonAndroid实现错误

Visual Studio 2019 中的 Git 同步

r - 使用 GIT 面板在 RStudio 中提交大量文件

git - git中强制推送和普通推送有什么区别

git - 使用不同分支构建 NodeMCU 固件

git - 为什么我在将新分支推送到我的 Git 存储库时遇到问题?

在 Raspberry Pi4 上下载 Go Mod