Git flag non-modified files as modified when gener

2019-05-23 12:22发布

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?

标签: git less
1条回答
别忘想泡老子
2楼-- · 2019-05-23 12:49

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.

查看更多
登录 后发表回答