Git - Windows AND linux line-endings
Asked Answered
M

2

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?

Mowry answered 5/1, 2016 at 11:32 Comment(3)
check: https://mcmap.net/q/11238/-trying-to-fix-line-endings-with-git-filter-branch-but-having-no-luckBrendis
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'.Mowry
Does this answer your question? How to change line-ending settingsNapalm
B
30

On Windows:

$ git config --global core.autocrlf true

On Linux:

$ git config --global core.autocrlf input

Read more about Dealing with line endings

Brendis answered 5/1, 2016 at 11:40 Comment(4)
This gives the same result... git status on linux gives empty result, git status on windows shows all files as modified.Mowry
$ git config --global core.autocrlf input was enough for me on Windows too.Instinct
beautiful! This worked for me. I was trying to share repo b/w windows and wsl, stored in windows FS.Eyepiece
This works great for wsl, thanks!Nick
A
19

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
Ambary answered 5/1, 2016 at 12:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.