2

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?

flob
  • 3,760
  • 2
  • 34
  • 57
Vadorequest
  • 16,593
  • 24
  • 118
  • 215
  • You should really add all generated files to your `.gitignore`, like any other build artifact (you don't put your `target` directory or binaries in the repo, if CSS isn't your source, it shouldn't be either). – ssube Nov 14 '14 at 15:07
  • Yeah, I know that. But I can't. – Vadorequest Nov 14 '14 at 15:43

1 Answers1

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.

flob
  • 3,760
  • 2
  • 34
  • 57
  • `git config core.autocrlf` => true in my current settings – Vadorequest Nov 14 '14 at 13:44
  • I have already tried that a month ago, it fixed a few problem when I downloaded files from git remote, so they would be encoded in `CLRF` in my computer, but it doesn't ignore them or help me with my current issue. Or I missed something. – Vadorequest Nov 14 '14 at 13:46
  • The thing is that LESS compiler *always* compile files using `LF` line endings, it doesn't seem to be customizable (I've asked) and the core.autoclrf is like ignored. – Vadorequest Nov 14 '14 at 13:47
  • Did you try *.css text eol=lf in your .gitattributes ? – flob Nov 14 '14 at 13:50
  • 1
    I guess I have to create a `.gitattributes` file in the project root folder, didn't know that, following doc at http://git-scm.com/docs/gitattributes – Vadorequest Nov 14 '14 at 13:57
  • I edited the answer to include your comment to make it easier for future visitors :-) – flob Nov 14 '14 at 14:06