Jason
Jason

Reputation: 4772

How do I tell my git tools to NOT transform line endings?

I'm using git across a number of platforms, and with containers, and am mounting filesystems between Windows and Linux containers. All the development tools I use can handle whatever line endings the source code has, silently, and sensibly. Except git.

I am finding git - commad line and desktop app - will transform line endings between Windows and Linux formats (CRLF ad LF). I don't want it to do that. I just want git to handle the files as supplied, and not try to second-guess how they are going to be used by transforming them. The transformed line endings is causing havoc. I create the files with LF line endings, and that is how I want them to stay, always, everywhere.

How can the git tools be told to leave the line endings alone? All documentation I have been able to find describe how to set various rules for different types of transforms for different tyoes of files within a specific repository. This is a function of my tools, not the repository. How do I set it for the tools to leave my file formatting well alone?

Upvotes: 1

Views: 102

Answers (1)

eftshift0
eftshift0

Reputation: 30166

Easiest way is to add this into .gitattributes:

*    -text

That should do. That is to tell git: I will take care of line endings.

There's important information in the comments (not necessarily from me) so make sure to read them.

Upvotes: 3

Related Questions