0

When I do git status I see this:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   project/schema-readme.md
        modified:   project/vp-automate.php

Strange thing is that those two files are not actually modified - they are binary the same, byte by byte.

Now I think I know why they are marked as modified by Git: it's because they use CRLF line endings while our project recently added a .gitattributes file with this content:

* text=auto eol=lf

This should mean that when committed, they will be actually updated by Git to have LF line endings. Is that why git status is marking those files as "modified" even though they are not currently modified?

EDIT: this is strange, there are many more files in my project that use CRLF line endings and are not detected as modified.. I don't understand what's so special about schema-readme.md and vp-automate.php that Git detects them as modified.

Borek Bernard
  • 50,745
  • 59
  • 165
  • 240

2 Answers2

1

Git detects changed files based on some file attributes in addition to the SHA1 checksums, which may be causing these two files to be marked as changed. More information about how Git detects file changes is in the answer to this question.

Community
  • 1
  • 1
0

Please try to configure the core.autoccrlf property. it is mostly used on Windows machines to make sure that local files use CRLF for line endings (so they work in notepad, etc), while files "inside" the repository are kept with "proper" LF endings.

From the docs (git config --help):

   core.autocrlf
       Setting this variable to "true" is almost the same as setting the text attribute to "auto" on all files except that text files are not guaranteed to be normalized: files that contain CRLF in the repository will not be touched. Use this setting if you want to have CRLF line endings in
       your working directory even though the repository does not have normalized line endings. This variable can be set to input, in which case no output conversion is performed.

Also see https://help.github.com/articles/dealing-with-line-endings#platform-all - as advised, on linux you should configure it to "input".

  • The thing is I don't want CRLF - for various reasons we need LF even on Windows. The question is solely about why Git detects some unchanged files as changed and if it has something to do with line endings. – Borek Bernard Nov 25 '14 at 14:50