【问题标题】:git svn introducing carriage returns?git svn 引入回车?
【发布时间】:2019-03-06 18:47:36
【问题描述】:

所以我目前正在尝试使用 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 在这里做什么;我在post 上找到了这些步骤。任何建议将不胜感激。

【问题讨论】:

    标签: git svn core.autocrlf


    【解决方案1】:

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

    * -text
    

    这样可以省去很多麻烦。

    【讨论】:

    • 此方法无效:(。我尝试在分支级别和用户级别添加 .gitattributes 文件。
    • 通常这是 git config 的罪魁祸首。当您将文件从原始位置复制到新存储库时,它们有什么类型的文件? (也就是说,在对它们运行任何 git 命令之前)。您可以为此使用filefile blahblah.txt。这应该告诉你它是否是 CRLF。
    猜你喜欢
    • 2014-07-10
    • 2015-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-04
    • 2010-09-20
    相关资源
    最近更新 更多