18

My main OS is windows 10.

I have an Ubuntu 14.04 box running in Vagrant that I develop my applications on. The box is running SMB which gives me root file access to the Ubuntu server.

On the Ubuntu server I have my application files in a GIT repo with a gitlab server as the origin.

I run SourceTree on my windows machine that connects to the ubuntu GIT repo through the SMB share (so I assume it uses my Windows GIT installation).

Git status on the ubuntu machine gives no changes.

Git status on Windows and SourceTree indicate that all the files have changed (because of the line endings).

What settings on which OS should I use in order to be able to use the same local repo on both Windows and Linux?

Basaa
  • 1,615
  • 4
  • 20
  • 41
  • check: http://stackoverflow.com/a/1511273/1327005 – Assem Jan 05 '16 at 11:49
  • Not a duplicate. Following their exact instructions still gives the exact same result. git status clean on ubuntu, all files modified on Windows/SourceTree. Problem here is that I use the exact same repo working copy on 2 OS'. – Basaa Jan 05 '16 at 12:00
  • 1
    Does this answer your question? [How to change line-ending settings](https://stackoverflow.com/questions/10418975/how-to-change-line-ending-settings) – Chiramisu Jan 13 '21 at 21:06

2 Answers2

30

On Windows:

$ git config --global core.autocrlf true

On Linux:

$ git config --global core.autocrlf input

Read more about Dealing with line endings

Assem
  • 11,574
  • 5
  • 59
  • 97
18

Set the autocrlf to the desired value:

How autocrlf works:

core.autocrlf=true:    core.autocrlf=input:      core.autocrlf=false:

       repo                     repo                    repo
    /        \               /        \              /        \
crlf->lf    lf->crlf     crlf->lf       \          /            \      
 /              \        /                \      /                \

Yet another way to show how autocrlf works

1) true:             x -> LF -> CRLF
2) input:            x -> LF -> LF
3) false:            x -> x -> x
CodeWizard
  • 128,036
  • 21
  • 144
  • 167