configuring git not to change the linendings

Viewed 20

I have a git repository, in which I want to have git leave the line endings of the files as it is, since the sw tool I use writes certain files with windows style and certain with linux style, regardless of the operating system the tool is running on. I don't want this definition to be global to all my repositories. I want it to be inside the repository, so that all the users will share the same crlf behaviour I saw that in .gitattributes, I can choose only from the 3 options: lf crlf binary (which is an alias to -merge -diff)

with lf/crlf, I need to specify file by file what is its crlf style, which is tedious. with binary, all files are as is, but when I use it, I see that tortoisegit, doesn't display how many lines has changed, since it treats it as binary. I assume I will also loose the option to merge files that are defined as binary. What I really want is just to define that git checks in and out as it is, without defining the files as binaries, and I want it to be done within the .gitattributes file is this posssible?

1 Answers

To mark some particular file as "do not touch line endings" (when line ending messing-about is otherwise enabled), simply list the file as -text in the appropriate .gitattributes entry. For instance:

precious.file   -text

prevents Git from messing with any file whose name component is precious.file (here or in any subdirectory).

Note that binary is effectively a macro attribute that means both -text and -diff (plus -merge as well); you want only -text.

Related