Git - Windows AND linux 行尾
Git - Windows AND linux line-endings
我的主要 OS 是 windows 10.
我在 Vagrant 中有一个 Ubuntu 14.04 box 运行ning,我在上面开发我的应用程序。该框是 运行ning SMB,它使我可以访问 Ubuntu 服务器的根文件。
在 Ubuntu 服务器上,我的应用程序文件位于 GIT 仓库中,以 gitlab 服务器为源。
我 运行 我的 windows 机器上的 SourceTree 通过 SMB 共享连接到 ubuntu GIT 存储库(所以我假设它使用我的 Windows GIT安装)。
Git ubuntu 机器上的状态没有变化。
Git Windows 和 SourceTree 上的状态表明所有文件都已更改(因为行尾)。
我应该在 OS 上使用什么设置才能在 Windows 和 Linux 上使用相同的本地存储库?
在 Windows:
$ git config --global core.autocrlf true
在 Linux:
$ git config --global core.autocrlf input
阅读更多关于 Dealing with line endings
将 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
我的主要 OS 是 windows 10.
我在 Vagrant 中有一个 Ubuntu 14.04 box 运行ning,我在上面开发我的应用程序。该框是 运行ning SMB,它使我可以访问 Ubuntu 服务器的根文件。
在 Ubuntu 服务器上,我的应用程序文件位于 GIT 仓库中,以 gitlab 服务器为源。
我 运行 我的 windows 机器上的 SourceTree 通过 SMB 共享连接到 ubuntu GIT 存储库(所以我假设它使用我的 Windows GIT安装)。
Git ubuntu 机器上的状态没有变化。
Git Windows 和 SourceTree 上的状态表明所有文件都已更改(因为行尾)。
我应该在 OS 上使用什么设置才能在 Windows 和 Linux 上使用相同的本地存储库?
在 Windows:
$ git config --global core.autocrlf true
在 Linux:
$ git config --global core.autocrlf input
阅读更多关于 Dealing with line endings
将 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