Git不会将.html文件视为二进制文件,即使在.gitattributes中将其标记为二进制文件也是如此。

时间:2019-03-25 20:24:22

标签: git diff 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>

因此,即使我在.gitattributes中明确列出了一个文件,它似乎也适用于所有文件类型 .html。

为什么?

1 个答案:

答案 0 :(得分:1)

根据评论,问题在于文件系统中有一个.gitattributes文件,该文件覆盖了顶层.gitattributes文件。