views:

102

answers:

1

I am programming on mac, and I don't really understand what Git does with the end of line of my files :

I created a repository with some files in Unix format (LF end of line).

When I clone the repository that I created, all my end of lines are CRLF. Shouldn't it detect automatically that I need LF end of line ?

I have autoclrf set to true.

GIT's documentation about autoclrf is pretty hard to understand :

If you simply want to have CRLF line endings in your working directory regardless of the repository you are working with, you can set the config variable "core.autocrlf" without changing any attributes.

[core]

   autocrlf = true

This does not force normalization of all text files, but does ensure that text files that you introduce to the repository have their line endings normalized to LF when they are added, and that files that are already normalized in the repository stay normalized.

The first sentence says "if you want to have all crlf", when the second sentence says that git will auto-adjust the end of lines.

In my case, it seems like Git converts everything to CRLF and leaves it like that when I try to clone.

+1  A: 

When you set core.autocrlf to true, Git converts line endings to LF when committing to the repo, but writes out files to the working tree using the line endings appropriate for your platform settings (LR on Mac/Unix/Linux, CRLF on Windows).

mipadi
so why do I get those ^M when editing the files after pulling from Git ?The file is a '.sh' and is executable.
Antonin
Are you seeing those control characters in the Git diff, or elsewhere?
mipadi
no, I don't ...
Antonin