Steve
Steve

Reputation: 2816

How to keep GIT from automatically converting end of line chars from DOS to Unix format?

We have a repository of code that was saved in DOS end of the line format. The managers plan on converting it to Unix format, eventually.

In the meantime, every time I commit code in GitLab it thinks every line is different.

The code is being developed and run in a Linux environment.

I set my Eclipse preferences to save in DOS end of the formatting.

However it seems like Git is automatically convert from DOS EOL characters to Unix EOL characters.

Is there something I can set in GIT, just for my branches only in my directories, without effecting anyone else, that will stop Git from doing that?

Upvotes: 1

Views: 3451

Answers (1)

ntshetty
ntshetty

Reputation: 1305

As per git help page dealing-with-line-endings

The git config core.autocrlf command is used to change how Git handles line endings. It takes a single argument.

On Windows, you simply pass true to the configuration. For example:

git config --global core.autocrlf true
# Configure Git on Windows to properly handle line endings

if don't have autocrlf then use .gitattributes file. as described in link

Upvotes: 1

Related Questions