我的主要操作系统是windows 10。
我有一个运行在Vagrant的Ubuntu 14.04盒子,我在上面开发我的应用程序。这个盒子运行SMB,它让我可以访问Ubuntu服务器的根文件。
在Ubuntu服务器上,我把我的应用程序文件放在一个以gitlab服务器为源的GIT repo中。
我在我的windows机器上运行SourceTree,该机器通过SMB共享连接到ubuntu GIT repo(所以我假设它使用我的windows GIT安装)。
ubuntu机器上的Git状态没有变化。
Windows和SourceTree上的Git状态表示所有文件都已更改(因为行结尾)。
为了能够在Windows和Linux上使用相同的本地repo,我应该在哪个操作系统上使用哪些设置?
在Windows上:
$ git config --global core.autocrlf true
在Linux上:
$ git config --global core.autocrlf input
阅读更多关于处理行尾的信息
将autocrlf
设置为所需值:
autocrlf
的工作原理:
core.autocrlf=true: core.autocrlf=input: core.autocrlf=false:
repo repo repo
/ / /
crlf->lf lf->crlf crlf->lf /
/ / /
展示autocrlf
如何工作的另一种方式
1) true: x -> LF -> CRLF
2) input: x -> LF -> LF
3) false: x -> x -> x