为什么Git的对待这个文本文件作为二进制文件? [英] Why does Git treat this text file as a binary file?

查看:2896
本文介绍了为什么Git的对待这个文本文件作为二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么混帐告诉我:

  $ git的差异MyFile.txt的
差异--git A / MyFile.txt的B / MyFile.txt的
指数d41a4f3..15dcfa2 100644
二进制文件/ MyFile.txt的和b / MYFILE.TXT不同

他们不是文本文件?

我已经检查了.gitattributes,它是空的。为什么我得到这个消息?我使用了我不能得到的diff

新增:

我注意到有一个 @ 中的文件的权限,这是什么?难道这是什么原因呢?

  $ LS -all
drwxr-XR-X 5 nacho4d人员170 7月28日17:07。
drwxr-XR-X 16 nacho4d人员544 7月28日16:39 ..
-rw-R - R的 - @ 1 nacho4d人员6148 7月28日16:15 .DS_Store
-rw-R - R的 - @ 1 nacho4d人员746 7月28日17:07 MyFile.txt的
-rw-R - R-- 1 nacho4d人员22538 4月5日16:18 OtherFile.txt


解决方案

它只是意味着当混帐检查文件的实际内容(不的知道的任何给定的扩展名是不是一个二进制文件 - 你可以使用的属性,如果你想明确告诉它的文件 - 见该男子页)

已经检查了文件的内容已经看到的东西,是不是在基本的ASCII字符。作为UTF16我预计,所以它认为这是二进制文件将有搞笑的字符。

有告诉git的,如果你有国际化(i18n)或文件扩展字符格式的方法。我不是足够新的设置,准确的方法 - 你可能需要RT [全文]中号;-)

编辑:快速搜索,所以找到<一href=\"http://stackoverflow.com/questions/777949/can-i-make-git-recognize-a-utf-16-file-as-text\">can-i-make-git-recognize-a-utf-16-file-as-text这应该给你一些线索。

I wonder why git tells me this:?

$ git diff MyFile.txt
diff --git a/MyFile.txt b/MyFile.txt
index d41a4f3..15dcfa2 100644
Binary files a/MyFile.txt and b/MyFile.txt differ

Aren't they text files?

I have checked the .gitattributes and it is empty. Why I am getting this message? I cannot get diffs as I use to anymore

ADDED:

I've noticed there is an @ in the file permissions, what is this? Could this be the reason?

$ls -all
drwxr-xr-x   5 nacho4d  staff    170 28 Jul 17:07 .
drwxr-xr-x  16 nacho4d  staff    544 28 Jul 16:39 ..
-rw-r--r--@  1 nacho4d  staff   6148 28 Jul 16:15 .DS_Store
-rw-r--r--@  1 nacho4d  staff    746 28 Jul 17:07 MyFile.txt
-rw-r--r--   1 nacho4d  staff  22538  5 Apr 16:18 OtherFile.txt

解决方案

It simply means that when git inspects the actual content of the file (it doesn't know that any given extension is not a binary file - you can use the attributes file if you want to tell it explicitly - see the man pages).

Having inspected the file's contents it has seen stuff that isn't in basic ascii characters. Being UTF16 I expect that it will have 'funny' characters so it thinks it's binary.

There are ways of telling git if you have internationalisation (i18n) or extended character formats for the file. I'm not sufficiently up on the exact method for setting that - you may need to RT[Full]M ;-)

Edit: a quick search of SO found can-i-make-git-recognize-a-utf-16-file-as-text which should give you a few clues.

这篇关于为什么Git的对待这个文本文件作为二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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