首页 > 解决方案 > Git 不会将 .html 文件视为二进制文件,即使它在 .gitattributes 中标记为二进制文件

问题描述

我试图让 git 将编译后的代码标记为二进制文件,以便清理差异。在大多数情况下,这是有效的,但不适用于.html文件。

这是我的.gitattributes

web/themes/custom/*/css/** -diff
web/themes/custom/*/dist/** -diff
web/themes/custom/*/pattern-lab/** -diff
web/themes/custom/*/pattern-lab/**/*.html -diff
web/themes/custom/columbia_sps/pattern-lab/public/patterns/00-base-global-01-colors-colors/00-base-global-01-colors-colors.html -diff

正如你所看到的,最后两行是我试图让它与更具体的东西一起工作。

这是一个差异

$ git show b118f56069f96cd9f1c60ca9d8eca1a213aeabc1
diff --git a/web/themes/custom/columbia_sps/dist/style.css b/web/themes/custom/columbia_sps/dist/style.css
index 2af390be7..9e0570210 100644
Binary files a/web/themes/custom/columbia_sps/dist/style.css and b/web/themes/custom/columbia_sps/dist/style.css differ
diff --git a/web/themes/custom/columbia_sps/dist/style.css.map b/web/themes/custom/columbia_sps/dist/style.css.map
index c558df481..1a6ac917c 100644
Binary files a/web/themes/custom/columbia_sps/dist/style.css.map and b/web/themes/custom/columbia_sps/dist/style.css.map differ
diff --git a/web/themes/custom/columbia_sps/pattern-lab/public/latest-change.txt b/web/themes/custom/columbia_sps/pattern-lab/public/latest-change.txt
index b8064ad75..cdea372dd 100644
Binary files a/web/themes/custom/columbia_sps/pattern-lab/public/latest-change.txt and b/web/themes/custom/columbia_sps/pattern-lab/public/latest-change.txt differ
diff --git a/web/themes/custom/columbia_sps/pattern-lab/public/patterns/00-base-global-01-colors-colors/00-base-global-01-colors-colors.html b/web/themes/custom/columbia_sps/pattern-lab/public/patterns/00-base-global-01-colors-colors/00-base-global-01-colors-colors.html
index 733999083..a9e9ba436 100644
--- a/web/themes/custom/columbia_sps/pattern-lab/public/patterns/00-base-global-01-colors-colors/00-base-global-01-colors-colors.html
+++ b/web/themes/custom/columbia_sps/pattern-lab/public/patterns/00-base-global-01-colors-colors/00-base-global-01-colors-colors.html
@@ -45,10 +45,10 @@
     <link rel="stylesheet" href="/libraries/select2/dist/css/select2.min.css"  media="all" />

     <!-- Pattern Lab base styles. -->
-    <link rel="stylesheet" href="../../../../dist/styleguide-specific.css?cacheBuster=1553203845">
+    <link rel="stylesheet" href="../../../../dist/styleguide-specific.css?cacheBuster=1553539945">

     <!-- Component styles -->
-    <link rel="stylesheet" href="../../../../dist/style.css?1553203845" media="all" />
+    <link rel="stylesheet" href="../../../../dist/style.css?1553539945" media="all" />

     <!-- Drupal-specific usage -->
     <!-- example using symlinking -->
<snip>

所以它似乎适用于.html 之外的所有文件类型,即使我在 .html 中明确列出了该文件.gitattributes

为什么?

标签: gitdiffgitattributes

解决方案


根据评论,问题是.gitattributes文件系统中有一个文件覆盖了顶级.gitattributes文件。


推荐阅读