从SVN迁移到git后,如何修复行结束问题? [英] How do I fix line ending issues after migrating from SVN to git?

查看:119
本文介绍了从SVN迁移到git后,如何修复行结束问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  git svn clone  -  stdlayout --authors-file = ourcommitters .txt svn://svn.internalserver.com 

当我这样做时, core.autocrlf'设置为'true' - 以防万一。



经过很长时间,命令完成。我清理了一下所产生的git仓库(删除无用的分支,创建标签等),现在一切都看起来非常好,并且运行良好。该仓库托管在一个Linux机器上,并将其克隆到其他Linux机器上运行得非常好。

然而,我注意到一个问题:在将存储库克隆到 Windows 框中,某些文件在切换分支时似乎被修改。例如,我这样做:

  git clone svn://our.git.server/foo 
git status #一切都干净
git checkout -t origin / maintenance#切换到维护分支
git status#一切都干净
git checkout master#返回主分支
git status#A很少有文件被修改!

执行'git diff'时,我发现修改后的文件似乎只有行结束。在研究这一点时,我们注意到这些文件在Subversion中使用CR-LF行尾(而不是LF行结尾)进行检查,并且这个错误被转换为我们的git存储库。



有没有办法在我们的仓库中解决这个问题(到目前为止,它没有经常被克隆,所以一些历史重写就可以)而不用做'清理提交'之类的事情?也许我们可以以某种方式无声地重写受影响的对象?或者,我们可以在Subversion中修复 - 然后再次发出上面的'git svn clone'命令。这似乎增量式工作(它只会选择最后一行结束修复提交),但是又一次 - 它创建一个提交。我想知道我是否能解决这个问题。

解决方案

事实证明,最简单的方法是修复Subversion中的错误文件,然后使用

  git svn clone  -  stdlayout --authors-file = ourcommitters.txt svn:// svn再次克隆。 internalserver.com 


I just finished converting a Subversion repository to git using

git svn clone--stdlayout --authors-file=ourcommitters.txt svn://svn.internalserver.com

While doing so, I had the git flag 'core.autocrlf' set to 'true' - just in case that matters.

After a long time, the command finished. I cleaned the resulting git repository a bit (deleting unneded branches, creating tags etc.) and now everything looks really nice and works well. The repository is hosted on a Linux box, and cloning that onto other Linux boxes works really well.

However, I noticed one problem: when cloning the repository onto a Windows box, some files appear to be modified when switching branches. For instance, I do this:

git clone svn://our.git.server/foo
git status                           # Everything is clean
git checkout -t origin/maintenance   # Switch to maintenance branch
git status                           # Everything is clean
git checkout master                  # Back to master branch
git status                           # A few files are modified!

When doing a 'git diff', I notice that the modified files seem to differ in nothing but their line endings. When researching this a bit, we noticed that these files had accidentally been checked in using CR-LF line endings (instead of LF line endings) in Subversion, and this bug was converted into our git repository.

Is there any way to fix this issue in our repository (so far it wasn't cloned very often, so some history rewriting would be fine) without doing a 'cleanup commit' or the like? Maybe we can silently rewrite the affected objects somehow?

Alternatively, we could fix this in Subversion - and then issue the 'git svn clone' command above again. This seems to work incrementally (it would just pick up the latest line ending fix commit) but again - it creates a commit. I wonder whether I can get around that.

解决方案

It turned out that the easiest way was to fix the faulty files in Subversion, and then clone again using

git svn clone--stdlayout --authors-file=ourcommitters.txt svn://svn.internalserver.com

这篇关于从SVN迁移到git后,如何修复行结束问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆