git-svn 可以像本地 subversion 客户端一样处理 CRLF 吗?

发布于 2024-07-26 17:23:42 字数 1125 浏览 10 评论 0原文

我有一个托管在 Linux 上的 Subversion 存储库,但只能通过 Windows 客户端访问,因为它是大型 Windows 应用程序的源代码。

如果我可以使用 git-svn (由 msysgit 提供)处理这个存储库,那就太棒了。

我花了很长时间试图让存储库不要陷入 Windows 风格行结尾的困境。

svn clone 后,使用以下命令签出 git 存储库:

  • core.autocrlf = true 显示对存储库中实际使用 LF 的任何文件的修改。
  • core.autocrlf = input 显示对存储库中实际使用 LF 的任何文件的修改。
  • core.autocrlf = false 显示对所有内容的修改。

这里最好的选择是什么? 我应该使用 core.autocrlf = true 并将受影响文件的 LF 更改提交到 CRLF 吗?

我差一点就认输了,直接将我的 Subversion 工作副本放入 git 存储库中。 这将是一个糟糕的解决方案,但至少允许当地分支机构和储藏室。 当文件被添加到 subversion 中时,不断添加文件显然会变得非常痛苦。

编辑:对于那些感兴趣的人。 如果你使用 Windows,git-svn 是一个巨大的痛苦。 hasen j 下面的答案可能是正确的,但我不能遵循他的建议,否则会引起团队中其他开发人员的愤怒。

我基本上放弃了这个问题,因为它不会导致合理的结果。 希望下一届 Google 代码之夏能够吸引那些想要获得“Windows 上正确的 git-svn 支持”项目的人。 请参阅http://git.or.cz/gitwiki/SoC2009Ideas#Propergit-svnsupportonWindows

I have a subversion repository hosted on Linux but only ever accessed via windows clients as it's for the source of a large Windows application.

It would be awesome if I could work on this repository using git-svn (provided by msysgit).

I'm having a heck of a time trying to get the repository to not get itself in a jam over the windows style line endings.

After svn clone a checkout of the git repository with:

  • core.autocrlf = true shows modifications to any file which actually does use LF in the repository.
  • core.autocrlf = input shows modifications to any file which actually does use LF in the repository.
  • core.autocrlf = false shows modifications to everything.

What's the best option here? Should I use core.autocrlf = true and commit the LF to CRLF changes for affected files?

I'm very close to throwing in the towel and just putting my Subversion working copy into a git repository. This would be a poor solution but would at least allow local branches and stashes. It will obviously become a huge pain to keep adding files when they are added to subversion.

EDIT: For those who are interested. git-svn is a royal pain if you are on Windows. hasen j's answer below is probably the right one but I can't follow his advice without attracting the ire of the other developers in my team.

I'm essentially abandoning this question since it isn't going to lead to a reasonable outcome. Hopefully the next Google Summer of Code will attract someone who wants to pickup their "Proper git-svn support on Windows" project. See http://git.or.cz/gitwiki/SoC2009Ideas#Propergit-svnsupportonWindows

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

栀梦 2024-08-02 17:23:42

帮自己一个忙,不要弄乱行尾,保持原样。 将 autocrlf 设置为 false。

Windows 中任何像样的文本编辑器都应该能够处理 UNIX 风格的行结尾。

core.autocrlf = false 显示对所有内容的修改。

我认为如果你只是事后才这样做,那对你没有任何好处。

您必须删除此存储库,将 autocrlf 设置为 false,然后进行克隆。

Do yourself a favor and don't mess with line-endings, keep them as-is. set autocrlf to false.

Any half-decent text editor in windows should be able to handle unix-style line endings.

core.autocrlf = false shows modifications to everything.

I think that if you only do that after the fact, it won't do you any good.

You have to delete this repository, set autocrlf to false, and then do the clone.

一百个冬季 2024-08-02 17:23:42

由于我的其他答案不太适用于你,这里有另一种处理这种情况的方法:

同时使用 svn 和 git; 在同一工作目录中。

您将主要使用 git、从上游存储库中提取、进行本地更改、本地分支等; 您在本地 git 项目上工作时通常所做的一切。

然后,当您想要提交到中央 svn 存储库时,请使用 svn 客户端。

我在这方面有一些经验,只是我不会执行 svn commit ,而是使用 svn diff 创建补丁并提交它(因为我没有提交访问权限) )。

Since my other answer doesn't apply well to you, here's another way to deal with the situation:

Use both svn and git; in the same working directory.

You'll mainly be working with git, pulling from the upstream repository, making local changes, local branches, etc; everything that you normally do when you work on a local git project.

Then, when you want to commit to the central svn repo, use the svn client.

I had some experience doing this, only I wouldn't do an svn commit, but instead create a patch with svn diff and submit it (since I had no commit access anyway).

后eg是否自 2024-08-02 17:23:42

我有类似的问题。
为了解决这个问题,在 git-svn 克隆之后,我将 unix2dos 应用于所有文件,因为在我的例子中,SVN 存储库中的所有文件都使用 CRLF。 所以,我想你应该在 git-svn 之后手动尝试 CRLF-LF 转换。

I had a similar problem.
To solve it, after the git-svn clone, I applied unix2dos to all files because, in my case, all files in the SVN repo used CRLF. So, I guess you should try the CRLF-LF conversion manually right after git-svn.

要走干脆点 2024-08-02 17:23:42

我通常使用 git-filter-branchrecode dos..ascii -f 来清理我的 git-svn 克隆。 (这也有助于 latin1..utf8 转换。)

I usually clean up my git-svn clone with git-filter-branch over recode dos..ascii -f. (This has also helped for latin1..utf8 conversion, as well.)

客…行舟 2024-08-02 17:23:42

通常,您需要像这样设置 core.autocrlf 选项:

git config core.autocrlf true

但是根据到这篇文章,看起来它与 git-svn 配合得不太好。 可能值得尝试一下 SVN 存储库的第二个安全副本,看看它是否有效。

Normally, you'd want to set the core.autocrlf option like so:

git config core.autocrlf true

But according to this article, it looks like it doesn't play well with git-svn specifically. It might be worth a shot in a safe second copy of your SVN repository to see if it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文