Git flag non-modified files as modified when gener

2019-05-23 12:25发布

问题:

I have an issue using git.

It basically flag files that haven't modified in two different cases:

  • When the file has been regenerated by my LESS file watcher (for unknown reason), the content hasn't changed, it is exactly the same as before.
  • When the lne separator has changed, because LESS use always LF for generated .css, whatever the line separator of the source file (less) is.

I've added a screenshot.

I don't understand why these files are flag as modified, it messes up my git because it cannot commit them. It's boring and recurrent in my projects.

Here is what I get with a git status command line:

    updated :         assets/linker/styles/common/alignment.css
    updated :         assets/linker/styles/common/badges.css
    updated :         assets/linker/styles/common/base.css
    updated :         assets/linker/styles/common/buttons.css
    updated :         assets/linker/styles/common/datatables.css
    updated :         assets/linker/styles/common/float.css
    updated :         assets/linker/styles/common/forms.css
    updated :         assets/linker/styles/common/panels.css
    updated :         assets/linker/styles/common/text.css
    updated :         assets/linker/styles/devices/layouts/devices_default.css
    updated :         assets/linker/styles/layouts/default.css
    updated :         assets/linker/styles/themes/ayolan.css
    updated :         assets/linker/styles/views/chart.css
    updated :         assets/linker/styles/views/home.css

Any workaround?

回答1:

How about telling git to ignore line endings?

git config core.autocrlf true 

and set your .gitattributes in your project root to

*.css text eol=lf

See gitattributes doc or dealing with line endings for more information.



标签: git less