dbv
dbv

Reputation: 429

How to get git not to do any line ending conversions except for specific file types

I would like git not to do any line ending conversions except for specific files (say .c and .h). I would like to do it through .gitattributes so I can override any environment on users' machines. This is primarily targeted at Windows clients.

I want something like this:

* -text

*.c eol=lf
*.h eol=lf

But git is just ignoring everything after the first line (it's performing no line end manipulation at all).

Is there a way to do this?

Upvotes: 1

Views: 417

Answers (1)

Kevin Burdett
Kevin Burdett

Reputation: 2982

The * -text line is explicitly declaring that all files should be handled as binary. This will supersede your EOL settings, as they only apply to text files. You can bypass this by forcing text mode on your whitelisted extensions.

* -text
*.c text eol=lf
*.h text eol=lf

GitHub has a good article on this, for more detail
https://help.github.com/articles/dealing-with-line-endings/

EDIT: re-read your post, and tailored the response to better match your requirements

Upvotes: 1

Related Questions