我如何让Git将文件视为二进制文件? [英] How do I make Git treat a file as binary?

查看:567
本文介绍了我如何让Git将文件视为二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个中等规模项目的问题,在这个项目中,由于git将它们视为文本并合并,视觉工作室项目文件一直存在问题。我想只是将文件设置为二进制文件,以便git不会自动合并这些文件。



有没有办法做到这一点?

解决方案

使用属性。把这样的东西放在 .gitattributes 文件中(如果它不存在,就创建它):

  *。sln binary 
* .suo binary
* .vcxproj binary

这里 binary 实际上是一个预定义的宏< a>,相当于 -diff -merge -text



如果你仍然能够看到您可以使用:

  *。sln -merge -text 

通过这种方式, *。sln 文件不会被合并,不会被标准化,但同时diff-able。

Having a problem with a medium sized project where visual studio project files keep having issues due to git treating them as text and merging. I'd like to just set the file as binary so that git won't auto merge these files ever.

Is there a way to do this?

解决方案

Yes, using attributes. Put something like this in your .gitattributes file (create it if it doesn't exist):

*.sln binary
*.suo binary
*.vcxproj binary

Here binary is actually a predefined macro, equivalent to -diff -merge -text.

If you want to still be able to see the diff, you can use:

*.sln -merge -text

This way, the *.sln files won't be merged, not have eol normalized, but meanwhile diff-able.

这篇关于我如何让Git将文件视为二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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