![](/img/trans.png)
[英]Fixing the line-endings in a Git repository using the `.gitattributes` file
[英]Git - Windows AND linux line-endings
我的主要操作系统是Windows 10。
我有一个在Vagrant中运行的Ubuntu 14.04盒子,我开发了我的应用程序。 该框正在运行SMB,它为我提供了对Ubuntu服务器的根文件访问。
在Ubuntu服务器上,我将我的应用程序文件放在GIT仓库中,并以gitlab服务器为原点。
我在我的Windows机器上运行SourceTree,通过SMB共享连接到ubuntu GIT仓库(所以我假设它使用我的Windows GIT安装)。
ubuntu机器上的Git状态不会发生任何变化。
Windows和SourceTree上的Git状态表示所有文件都已更改(因为行结尾)。
为了能够在Windows和Linux上使用相同的本地存储,我应该使用哪些操作系统设置?
在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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.