首页 > 解决方案 > git svn 引入回车?

问题描述

所以我目前正在尝试使用 git-svn 将来自 git repo 的代码合并到我的 svn repo 中。我在 svn repo 中的代码是在 linux 上开发的,没有任何回车,我相信 git repo 中的代码也是在 linux 上开发的,因为我也没有在文件中看到回车。这是我将文件从 git repo 拉入 svn repo 的方法:

1. mkdir new_directory
2. cp -a /path/to/git/repo/. new_directory && cd new_directory
3. rm -rf .git/
4. git init
5. vim .git/config (and add):
  [svn-remote "svn"]
    url = https://link/to/svn/repo
    fetch = :refs/remotes/git-svn
6. git add .
7. git commit -m "message"
8. git svn fetch svn
9. git checkout -b svn git-svn
10. git merge master

一旦我点击第 10 步,我就会在每个文件中收到合并冲突的消息。经过调查,我发现我的 svn repo 中的每个文件现在都有回车,因为某种原因。我已经尝试添加autocrlf = input到 .git/config ,但它只解决了一小部分文件中的问题。我不太确定 git-svn 在这里做什么;我在这篇文章中找到了这些步骤。任何建议将不胜感激。

标签: gitsvncore.autocrlf

解决方案


Git 具有可以轻松破坏更改 EOL 的项目的配置内容。我认为你能做的最好的就是再试一次,但让 git 知道你想保持文件原样。您可以通过将此行添加到 .gitattributes 在分支级别(如在项目内部)执行此操作:

* -text

这样可以省去很多麻烦。


推荐阅读