Git - Windows AND linux line-endings

纵然是瞬间 提交于 2019-12-01 16:15:17

问题


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?


回答1:


On Windows:

$ git config --global core.autocrlf true

On Linux:

$ git config --global core.autocrlf input

Read more about Dealing with line endings




回答2:


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


来源:https://stackoverflow.com/questions/34610705/git-windows-and-linux-line-endings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!