SubGit和.gitattributes [英] SubGit and .gitattributes

查看:186
本文介绍了SubGit和.gitattributes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将SVN存储库导入到Git中,并且我有很多设置为svn:eol-style的文件. SubGit 读取这些属性,并为每个文件生成一个.gitattributes行.

I'm importing an SVN repository into Git, and I have a lot of files with svn:eol-style set. SubGit reads those properties and generates a .gitattributes line for every file.

是否有一种方法可以告诉它对每种类型的文件使用单线(即*.java text*.java text eol=lf,因为我们有强制执行此操作的样式指南规则)?

Is there a way to tell it to use a single-liner for every type of file (i.e. *.java text or *.java text eol=lf since we have a style guide rule which mandates that)?

我试图在导入之前将info/attributes添加到存储库中,但是生成的.gitattributes没有任何变化.

I tried to add the info/attributes to the repository just before the import, but there's no change in the generated .gitattributes.

有办法吗?

推荐答案

目前尚无法为初始翻译定义默认规则,例如*.java test eol=lf,但是如果您稍后在Git分支中,请更改.gitattributes来替换所有规则每个带有一个*.java test eol=lf规则的文件行,所有随后的带有svn:eol-style = LF的Java文件都不会导致换行,但是具有其他svn:eol-style值的Java文件将导致其他行,作为*.java test eol=lf规则.

At the moment there's no way to define default rules like *.java test eol=lf for initial translation, but if you later in a Git branch change .gitattributes to replace all per-file lines with one *.java test eol=lf rule, all subsequent Java files with svn:eol-style=LF won't result into new lines, but Java files with other svn:eol-style values will result into additional lines as exceptions to the *.java test eol=lf rule.

此外,甚至建议使用*.java test eol=lf规则,因为当您在Git中创建Java文件时,.gitattributes规则会隐式应用到它,因此您新创建的Java文件将自动具有"eol = lf"当您将其推入Git时,SubGit会将其转换为svn:eol-style = LF.因此,此规则的作用方式与SVN自动属性相同.

Moreover it is even recommended to have the *.java test eol=lf rule, because when you create a Java file in Git, .gitattributes rules are applied to it implicitly, so your newly created Java file will have "eol=lf" automatically and when you push it to Git, SubGit will translate it to svn:eol-style=LF. So this rule would act in the same way as SVN auto-properties.

SubGit根本不考虑info/attributes文件,因为它没有版本化,并且仅在SubGit在服务器端级别工作时才存在于本地计算机上.但是,如果只需要在一台计算机上使用它,则可以在本地计算机上使用info/attributes覆盖.gitattributes.

SubGit doesn't consider info/attributes file at all, because it is not versioned and exists on local machine only while SubGit works on the server-side level. But you can use info/attributes on the local machine to override .gitattributes if you need that on one machine only.

我还要注意,更改.gitattributes文件时应格外小心.当您将这种更改推送到SVN时,它将为所有更改了有效"eol"属性值的文件更新svn:eol样式.

I would also note that you should be careful when you change the .gitattributes file. When you push such a change to SVN, it will update svn:eol-style for all files for which the effective "eol" attribute value was changed.

另一个注意事项:为包含混合EOL的文件设置"eol"属性时要小心:首先在Git Blob级别将其EOL更改为LF,或者(这会更容易)将svn:eol-style属性设置为而是使用SVN端,因为当您设置此属性时,Subversion会自动修复文件内容,但是Git不会这样做.

One more note: be careful when you set the "eol" attribute for a file with mixed EOLs: change its EOLs to LF first at the Git blob level, or (what would be easier) set the svn:eol-style property on the SVN side instead, because when you set this property, Subversion automatically fixes file content, but Git doesn't do that.

您已经提到了两种模式,*.java text*.java text eol=lf,但是它们实际上是不同的.第一个是默认* text=auto !eol规则的特殊情况,除非Java文件包含二进制字符(因为它不包含"eol"属性,所以主* -rule会将其设置为!eol,即svn:eol-style = native);因此添加时将被忽略.第二个将为添加到Git的每个Java文件设置svn:eol-style = LF.

You've mentioned two patterns, *.java text or *.java text eol=lf, but they are actually different. The first one is a particular case of a default * text=auto !eol rule, unless the Java file contains binary characters (as it doesn't contain the "eol" attribute, the main *-rule will set it to !eol, what corresponds to svn:eol-style=native); so it would be ignored when added. The second one will set svn:eol-style=LF for every Java file added to Git.

最后,在将来的版本中,我们(SubGit团队)计划添加一种可能性,以为初始翻译指定默认的*.java test eol=lf规则,或者根据每个扩展的统计信息推论出该规则,但现在您应该手动添加此行到与您合作的每个Git分支.

Finally, in the future versions, we (the SubGit team) plan to add a possibility to specify default *.java test eol=lf rules for initial translation or deduce it basing on per-extension statistics, but for now you should add this line manually to every Git branch you work with.

这篇关于SubGit和.gitattributes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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