2

I checked out the repository, switched to the remote branch, so now I'm on detached HEAD. I haven't made any changes to the files, however, when I type git status it shows several files with changes. There are no intricate mechanisms which might cause the files to change. The changes are like this:

File status:

-- class Foo {
--   int x;
--   int y;
-- };
++ class Foo {
++   int x;
++   int y;
++ };

I know, this kind of behaviour shows up when you mess with line endings. However, both versions of the file have identical line endings. So there is really NO changes at all.

Even if I discard the changes and check the status, the files show up as changed again.

The solution Why does git think each line of an untouched file has changed is dangerous and misleading. I do care about line endings. I have .gitattributes file describing each file type and corresponding line ending. I also renormalized repository according to GitHub's recommendations. Still, when I do checkout, this problem persists. The workaround is make useless commit and switch back to my branch, however it is hacky and not robust enough for me.

My .gitattributes file content:

*.cs text eol=crlf
*.txt text eol=crlf
*.prefab text eol=lf
*.unity text eol=lf
*.meta text eol=lf
*.png binary
*.jpg binary
*.psd binary
*.dll binary
Community
  • 1
  • 1
GuardianX
  • 515
  • 11
  • 29
  • 2
    http://stackoverflow.com/q/2825428/1190388 – hjpotter92 Mar 27 '15 at 08:54
  • 1
    Would http://stackoverflow.com/a/27439837/6309 help? – VonC Mar 27 '15 at 09:04
  • possible duplicate of [Why does git think each line of an untouched file has changed](http://stackoverflow.com/questions/27438195/why-does-git-think-each-line-of-an-untouched-file-has-changed) – musiKk Mar 27 '15 at 09:20
  • I did read the solution on GitHub. I already incorporated it into out repository prior to this issue. The rest articles suggest changing core.autocrlf to false, which is misleading if I rely on different line endings for my toolchains (and I do). – GuardianX Mar 30 '15 at 09:14
  • What value of `core.autocrlf` do you have? – phts Mar 30 '15 at 10:00
  • @phts it is false, but it doesn't matter, since I have .gitattributes handling line endings for each file type. – GuardianX Mar 30 '15 at 10:55
  • Please show your .gitattributes file content in this case – phts Mar 30 '15 at 10:57
  • @phts updated the original post with my .gitattributes file content. – GuardianX Mar 30 '15 at 11:12
  • Show a hex dump so we can see what bytes are different? – Edward Thomson Mar 30 '15 at 12:15
  • @EdwardThomson hex dump of what exactly? Console diff output? – GuardianX Mar 30 '15 at 15:41
  • Ideally the changed region in both files, without having gone through `git diff` or a pager. But that would probably be fine as well. – Edward Thomson Mar 30 '15 at 15:56
  • @EdwardThomson they are identical. Even the line endings are the same. – GuardianX Mar 31 '15 at 08:05
  • When you do a `git hash-object` and a `git ls-files -s` on the offending file, are the resulting hashes different? If so, you are probably in the situation described at http://stackoverflow.com/questions/19686419/changes-in-git-working-directory-refuse-to-be-reverted. – David Deutsch Jun 06 '15 at 21:06

0 Answers0