views:

25

answers:

1

Hi,

In our development environment we use Windows, Mac, and Linux. I am having trouble when it comes to the commit -> pull -> push work flow.

The problem is end of line characters. If someone makes an edit on Mac and some one else makes an edit on Windows they conflict when pulling. The diff shows the entire file as different because the line endings have changes.

So my question is how can I setup all environments to convert all line endings to just LF when committing. And when pulling, don't change the line ending, leave it as LF.

+2  A: 

What you're asking for is for everyone to set the config parameter core.autocrlf to input, which will cause line ending normalization on input (that is, data going into the repository; committing) but not on output (data coming out of the repository; checking out, which happens during a pull).

However, you may not actually want to do this. The ideal thing is for everyone to simply configure their editors correctly. Most programmers' editors are reasonably intelligent about this - they'll detect line endings and use the same line endings when writing back to the file. Some editors may need a little help.

(See for example VonC's answer here, and other SO questions about autocrlf.)

Jefromi
The problem is that we use a plethora of different editors (Netbeans, TextMate, Notepad++, MS Write, nano, vim, GitX, SmartGit, etc) I it won't be practical to adjust their settings on every machine. Ill have a look into the `autocrlf input`
Petah
@Petah: But you have to adjust this config value on every machine too. I know, it's the same adjustment everywhere, it's easy to let git fix it for you. I'm just trying to provide the balancing viewpoint too: do it right in the first place.
Jefromi
The first place was a long time ago.
Petah
@Petah: By "the first place" I mean "when creating/editing content", not "when editing content". If you want it all to be LF not CRLF in the repo, there's still going to have to be a commit that changes it, no matter what solution you use.
Jefromi