1

背景:

我有两个 Unity3d 项目:

  • 第一个其 Unity 首选项设置为“混合资产”模式(一些文件是文本,一些是二进制文件)和
  • 第二个,其首选项设置为“强制文本”(大多数二进制文件都被翻译成YAML文本,因此几乎所有文件都可以diff编辑)。

为了将第一个项目的文件设置为文本/二进制文件,我们的~/.subversion/config文件已svn auto-props启用以及文件列表及其 svn 属性(*.cs文件设置为svn:eol-style=native*.unity文件设置为svn:mime-type=application/octet-stream,等等)。

问题:

由于我们的第二个项目现在支持所有文件的文本模式,我们需要使用一组不同的auto-props规则,因此*.unity文件现在被处理为svn:eol-style=native.

我看到git可以.gitattributes在每个项目(或每个目录)的基础上使用它,所以我们可以拥有这个功能。SVN 可以使用我们可以在我们的 repo 中共享的某种文件来做到这一点,这样每个提交的人都将使用相同的默认设置吗?

4

1 回答 1

2

One of the things you must understand that in git there's no real difference between a repository and a working directory. When you pull from a parent repository, you create your own repository.

.Gitattributes affect your local repository and only your local copy. Someone else can change their .gitattributes for their repository. After all, it's their repository. If a parent repository is receiving changes, it can use a pre-receive hook to verify the retrieved packet to make sure it follows the parent repository's policy. You shouldn't use .gitattributes to enforce policy, only to help you follow policy.

Subversion's auto-properties configuration is similar. It affects all working copies of that user. There's no individual configuration for each working copy. You can use a --config-dir parameter on many Subversion commands to specify a different Subversion configuration file for that operation, so you could have multiple configuration files and use --config-dir to specify that file. It's not convenient, but it's possible.

If you want to make sure your properties are set correctly, you need a pre-commit hook that checks the properties on a commit and rejects commits with invalid properties or property values on the files. I have a pre-commit hook that can do just that.

于 2012-10-11T19:51:41.260 回答