Subversion 可以为单个文件进行 EOL 转换设置。实际上 Git 也以 .gitattributes 文件('text' 和 'eol' 属性)的形式拥有它。对于一般情况 core.autocrlf 是不够的。
如果将其设置为 false,则所有具有 svn:eol-style=native 的文件都将以 git-svn 工作副本结尾的 LF 行,这对于 Windows 来说是不期望的。
如果将其设置为 true,则所有行尾都将转换为 LF,并以 LF 的形式(始终)发送到 SVN。
实际上svn:eol-style=unset
应该对应 '-text' git 属性(这意味着没有转换),svn:eol-style=LF
--- 到 'eol=lf' 属性和svn:eol-style=CRLF
--- 到 'eol=crlf' 属性;svn:eol-style=native
取决于系统,因此可以通过未版本化的 eol 设置来控制,因此相应的 git 属性是“!eol”(这意味着从core.eol
.git/config 中获取 EOL 设置)。
除了 git-svn,您可以使用任何可以将 svn:eol-style 转换为单个文件的相应 .gitattirbutes 值的解决方案,反之亦然。一种解决方案是服务器端:您将SubGit安装到您的 SVN 存储库中,然后使用 SubGit 将创建的纯 Git 接口:
$ subgit install path/to/svn/repository
# Git interface with correct .gtattributes repository will appear at path/to/svn/repository/.git
# you should setup an access to it
然后在客户端克隆它并将 core.eol 设置为 Windows 的“crlf”和其他操作系统的“lf”(默认值为“lf”)。
$ git clone <URL> working_tree
$ cd working_tree
$ git config core.eol crlf #for Windows only
之后,Git 的行为方式与 SVN 相同。
或者在客户端,您可以使用SmartGit:您可以使用它克隆 SVN 存储库(不打开现有的 git-svn 存储库)--- 然后它将 svn:eol-style 转换为 .gitattributes。这种情况不需要额外的 core.eol 设置,SmartGit 会关心它。