使github使用.gitattributes“ binary”。属性 [英] Make github use .gitattributes "binary" attribute

查看:167
本文介绍了使github使用.gitattributes“ binary”。属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我需要将一些文件跟踪到版本控制中,在此示例中为csv文件。但是文件包含大量行,并导致Github偶尔强制执行必须通过代码审查才能接受和合并请求请求的文件。

In my project, I need to track some files into version control, csv files in this example. But the files contain a considerable amount of lines and cause Github to occasionally supress files that must go through code review for pull requests to be accepted and merged.

我尝试使用 .gitattributes 将此类文件标记为二进制文件,或者只是使用以下方式将它们标记为差异:

I tried using .gitattributes to mark such files either as binaries or just to not being diplayed in the diff using:

+*.csv -diff
+*.csv -merge
+*.csv binary

一次,并将其组合。

$ git diff HEAD^
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..8a86f80
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*.csv -diff -merge binary
diff --git a/AssetsImportCompleteSample.csv b/AssetsImportCompleteSample.csv
new file mode 100644
index 0000000..5b20a6e
Binary files /dev/null and b/AssetsImportCompleteSample.csv differ

但是当分支被推送到Github并与另一个分支进行比较时,Github会忽略这些属性并将文件diff显示为文本,尽管.gitattributes是自定义差异显示的方式:

but when the branch is pushed to Github and compared against another branch, Github ignores these attributes and displays the file diff as text, though .gitattributes is "customizing" the way the diff should be displayed:

是否有任何方法可以强制Github中的差异考虑 .gitattributes 中的属性来自定义差异的行为

Is there any way to force the diff in Github consider the attributes in .gitattributes to customize the behavior of the diff so that the diff of the indicated files is supressed?

预先感谢!

推荐答案

我曾问过与Github类似的问题,即

I had asked the similar question to Github that


无论如何,是否有使用.git属性来抑制机器$ b的差异$ b生成的代码需要版本化,而
无法使用.gitignore文件忽略?

Is there anyway to suppress using .gitattributes the diff of machine generated codes which needs to be versioned and cannot be ignored by using .gitignore file?


GitHub不使用.gitattributes文件来选择要在差异中显示的
文件,因此无法

GitHub doesn't use .gitattributes files for choosing which files to show in a diff, so it's not possible to get around this that way.

抑制差异中某些文件的唯一当前方法是让
被Linguist分类为生成:

The only current way to suppress certain files in a diff, is to have the classified as "generated" by Linguist:

https://github.com / github / linguist#generation-file-detection

如果您要这样做,将需要检查$$$ b语言学家如何将文件分类为生成的详细信息,并确保文件
符合条件。我不能说这对于您想从差异中抑制的特定文件
是否可行。

If you want to do that, you would need to check out the details of how Linguist classifies files as "generated" and make sure that your files qualify. I cannot say whether this is doable for the specific files which you are interested in suppressing from the diff.

目前,Github不支持.gitattributes文件来抑制任何差异。

So, for now Github does not support .gitattributes file to suppress any diff.

这篇关于使github使用.gitattributes“ binary”。属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆