[英]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.