1

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?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Steve
  • 3,127
  • 14
  • 56
  • 96
  • 3
    Possible duplicate of [git replacing LF with CRLF](https://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf) – Daniel Mann Apr 11 '18 at 21:54
  • @Daniel nearly all answers are false now. The only good solution is to use a `.gitattributes` file – Philippe Apr 11 '18 at 23:19

1 Answers1

1

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

ntshetty
  • 1,293
  • 9
  • 20
  • As mentioned in [dealing-with-line-endings](https://docs.github.com/en/github/using-git/configuring-git-to-handle-line-endings), be sure to issue the following to complete the conversion: `git add --renormalize .` – nOw Innovation Inc. Feb 10 '21 at 15:20