澄清/清理GIT中的行结束问题 [英] Clarifying/clearing up line ending issues in GIT

查看:83
本文介绍了澄清/清理GIT中的行结束问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个从subversion导出到git的仓库。该存储库由Mac,Linux和PC用户使用。毋庸置疑,行结局是一团糟。一些文件以CRLF,LF或CR结尾,一些文件可以在两个或三个文件中混合使用。



添加 autocrlf = true 似乎稍微解决了一些问题。然而,差异有时很奇怪,即对文件进行单行编辑会使差异中的所有行显示更改(我认为这是由于文件的行结尾都被重写),有时会将一行编辑为文件正常工作。



是否有网站,或者有人可以解释我们如何解决这个问题?是否有一个我们必须设置的git设置,或者我们必须对所有文件进行批量更新才能得到某一行结束或什么?

任何帮助都会非常感谢,因为它相当混乱!



(以下

这个相关的SO问题将引起您的兴趣:



这里是链接到类似的建议来自Github。

另外,正如Greg Hewgill的帖子中提到的那样,验证未来的提交者使用编辑器可以正确处理新的行结束策略是明智的。



当你说添加autocrlf = true似乎稍微修复了一些事情。我假设这是通过使用 .gitattributes


We have a repository that was exported from subversion into git. This repository is used by Mac, Linux, and PC users. Needless to say the line endings are a mess. Some files end in CRLF, LF, or CR and some have a mix between all two or three in one file.

Adding autocrlf = true seems to fix things slightly. However the diffs come up quite strange at times, ie a one line edit to a file makes all lines appear changed in the diff (I assume it was due to the line endings for the file were all rewritten) and sometimes one line edits to a file works correctly.

Is there a website, or could someone please explain how we can sort this mess out? Is there a git setting we have to set, or do we have to do a bulk update of all the files to have a certain line ending or what?

Any help would be much appreciated as its quite a mess!

(The following stackoverflow post appears it might help, although it doesnt answer what happens when we have another mac or pc or linux user commit another patch)

解决方案

This related SO question will be of interest to you:

Trying to fix line-endings with git filter-branch, but having no luck

And here is a link to similar advice from Github.

Also, as mentioned in Greg Hewgill's post it is wise to verify that future committers use an editor which handles the new line-ending policy correctly.

When you say "Adding autocrlf = true seems to fix things slightly." I assume this was done in using .gitattributes.

这篇关于澄清/清理GIT中的行结束问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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