为什么我的 git 突然神奇地能够显示 pdf 文件的文本差异?
Why is my git suddenly magically capable of showing text diffs for pdf files?
我的 Windows 10 计算机上有 git 版本 2.17.0.windows.1
。据我所知,git 不应该开箱即用地区分 pdf 文件。我一直希望差异消息只是说 "Binary files a.pdf and b.pdf differ".
所以我很惊讶有一天看到控制台在一个存储库中打印出这个,其中包含一个已更新的 pdf 文件:
diff --git a/assign6.pdf b/assign6.pdf
index 6e6e292..cf8f0bc 100644
--- a/assign6.pdf
+++ b/assign6.pdf
@@ -6,7 +6,7 @@
Late Date: NO LATE
- November 10, 2018
+ November 26, 2018
This assignment introduces tasks with public members, direct communication and high-level techniques for structuring
complex interactions among tasks (versus monitor and semaphore structuring approaches). Use it to become familiar
我知道有一种方法可以使用 gitconfig 中的 textconv 设置和 git 属性中特定文件扩展名的 diff 属性来显示人类可读的 diffs for binary files,但是我当然没有为我的电脑做过那样的事情。我只是使用 exe 安装程序安装了 git,从那以后我没有真正更改任何配置设置。
这是 git config --list
在该文件夹中显示的内容:
core.symlinks=false
core.autocrlf=false
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
user.email={{super secret email}}
user.name={{super secret username}}
core.pager=less
core.autocrlf=false
core.whitespace=cr-at-eol
color.ui=auto
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url={{super secret url}}
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
我最初认为这是最近添加到 git 中的一些新功能,但是当我在具有 git 版本的 Ubuntu 16.04 机器上尝试 diff 时 2.19.0
,这是控制台打印出来的:
diff --git a/assign6.pdf b/assign6.pdf
index 6e6e292..cf8f0bc 100644
Binary files a/assign6.pdf and b/assign6.pdf differ
那么……好像不是?
那么这个神奇的独角兽 pdf 差异行为从何而来?这是在哪里配置的?
因为 Git for Windows 2.18 提到
The diff filter for .pdf files was fixed.
按理说 2.17 包含一个用于 pdf 的 diff 过滤器。
您可以在 git-for-windows/build-extra/.
中查看其设置
我的 Windows 10 计算机上有 git 版本 2.17.0.windows.1
。据我所知,git 不应该开箱即用地区分 pdf 文件。我一直希望差异消息只是说 "Binary files a.pdf and b.pdf differ".
所以我很惊讶有一天看到控制台在一个存储库中打印出这个,其中包含一个已更新的 pdf 文件:
diff --git a/assign6.pdf b/assign6.pdf
index 6e6e292..cf8f0bc 100644
--- a/assign6.pdf
+++ b/assign6.pdf
@@ -6,7 +6,7 @@
Late Date: NO LATE
- November 10, 2018
+ November 26, 2018
This assignment introduces tasks with public members, direct communication and high-level techniques for structuring
complex interactions among tasks (versus monitor and semaphore structuring approaches). Use it to become familiar
我知道有一种方法可以使用 gitconfig 中的 textconv 设置和 git 属性中特定文件扩展名的 diff 属性来显示人类可读的 diffs for binary files,但是我当然没有为我的电脑做过那样的事情。我只是使用 exe 安装程序安装了 git,从那以后我没有真正更改任何配置设置。
这是 git config --list
在该文件夹中显示的内容:
core.symlinks=false
core.autocrlf=false
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
user.email={{super secret email}}
user.name={{super secret username}}
core.pager=less
core.autocrlf=false
core.whitespace=cr-at-eol
color.ui=auto
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url={{super secret url}}
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
我最初认为这是最近添加到 git 中的一些新功能,但是当我在具有 git 版本的 Ubuntu 16.04 机器上尝试 diff 时 2.19.0
,这是控制台打印出来的:
diff --git a/assign6.pdf b/assign6.pdf
index 6e6e292..cf8f0bc 100644
Binary files a/assign6.pdf and b/assign6.pdf differ
那么……好像不是?
那么这个神奇的独角兽 pdf 差异行为从何而来?这是在哪里配置的?
因为 Git for Windows 2.18 提到
The diff filter for .pdf files was fixed.
按理说 2.17 包含一个用于 pdf 的 diff 过滤器。
您可以在 git-for-windows/build-extra/.