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
Per this helpful answer, you can ask Git directly why it treats a file in a particular way:
It produces useful output like this:
If you have not set the type of a file, Git tries to determine it automatically and a file with really long lines and maybe some wide characters (e.g. Unicode) is treated as binary. With the .gitattributes file you can define how Git interpretes the file. Setting the diff attribute manually lets Git interprete the file content as text and will do an usual diff.
Just add a .gitattributes to your repository root folder and set the diff attribute to the paths or files. Here's an example:
If you want to check if there are attributes set on a file, you can do that with the help of git check-attr
Another nice reference about Git attributes could be found here.
Git will even determine that it is binary if you have one super-long line in your text file. I broke up a long String, turning it into several source code lines, and suddenly the file went from being 'binary' to a text file that I could see (in SmartGit).
So don't keep typing too far to the right without hitting 'Enter' in your editor - otherwise later on Git will think you have created a binary file.
This is also caused (on Windows at least) by text files that have UTF-8 with BOM encoding. Changing the encoding to regular UTF-8 immediately made Git see the file as type=text
I just spent several hours going through everything on this list trying to work out why one of the test projects in my solution wasn't adding any tests to the explorer.
It turned out in my case that somehow (probably due to a poor git merge somewhere) that VS had lost a reference the project altogether. It was still building but I noticed that it only built the dependancies.
I then noticed that it wasn't showing up in the dependencies list itself, so I removed and re-added the test project and all my tests showed up finally.
I was having this issue where Git GUI and SourceTree was treating Java/JS files as binary and thus couldn't see difference
Creating file named "attributes" in .git\info folder with following content solved the problem
If you would like to make this change for all repositories then you can add attributes file in following location $HOME/.config/git/attributes