-
-
Save webbertakken/ff250a0d5e59a8aae961c2e509c07fbc to your computer and use it in GitHub Desktop.
| # | |
| # Git attributes for Unity projects | |
| # | |
| # Compiled by the GameCI community under the MIT license - https://game.ci | |
| # | |
| # Latest version at https://gist.github.com/webbertakken/ff250a0d5e59a8aae961c2e509c07fbc | |
| # | |
| # Ensure that text files that any contributor introduces to the repository have their line endings normalized | |
| * text=auto | |
| # Increase probability of success for merging files with specific extensions | |
| *.cs diff=csharp | |
| # Macro attribute: Files with Unity's yaml format | |
| # linguist-generated means the file is ignored for the repository's language statistics and diffs are hidden by default. | |
| [attr]unity-yaml-file -text merge=unityyamlmerge linguist-generated | |
| # Macro attribute: Files intended for LFS | |
| [attr]lfs-file filter=lfs diff=lfs merge=lfs -text | |
| # Unity files | |
| *.asmdef unity-yaml-file -linguist-generated | |
| *.anim unity-yaml-file | |
| *.asset unity-yaml-file | |
| *.brush unity-yaml-file | |
| *.controller unity-yaml-file | |
| *.flare unity-yaml-file | |
| *.fontsettings unity-yaml-file | |
| *.giparams unity-yaml-file | |
| *.guiskin unity-yaml-file | |
| *.mask unity-yaml-file | |
| *.mat unity-yaml-file | |
| *.meta unity-yaml-file | |
| *.mixer unity-yaml-file | |
| *.overrideController unity-yaml-file | |
| *.physicMaterial unity-yaml-file | |
| *.physicsMaterial2D unity-yaml-file | |
| *.playable unity-yaml-file | |
| *.prefab unity-yaml-file | |
| *.preset unity-yaml-file | |
| *.renderTexture unity-yaml-file | |
| *.shadervariants unity-yaml-file | |
| *.spriteatlas unity-yaml-file | |
| *.terrainlayer unity-yaml-file | |
| *.unity unity-yaml-file | |
| # Unity binary files | |
| *.bundle lfs-file | |
| *.cubemap lfs-file | |
| *.unitypackage lfs-file | |
| # Unity specific assets | |
| *-[Nn]av[Mm]esh.asset lfs-file | |
| *-[Tt]errain.asset lfs-file | |
| *LightingData.asset lfs-file | |
| *OcclusionCullingData.asset lfs-file | |
| # Creative software | |
| *.rns lfs-file | |
| *.reason lfs-file | |
| *.lxo lfs-file | |
| *.exr lfs-file | |
| # Documents | |
| *.pdf lfs-file | |
| # Image formats | |
| *.afdesign lfs-file | |
| *.afphoto lfs-file | |
| *.ai lfs-file | |
| *.bmp lfs-file | |
| *.dds lfs-file | |
| *.jpg lfs-file | |
| *.gif lfs-file | |
| *.iff lfs-file | |
| *.pict lfs-file | |
| *.png lfs-file | |
| *.psd lfs-file | |
| *.svg lfs-file | |
| *.tga lfs-file | |
| *.tiff lfs-file | |
| *.webp lfs-file | |
| # Audio formats | |
| *.aif lfs-file | |
| *.aiff lfs-file | |
| *.it lfs-file | |
| *.mod lfs-file | |
| *.mp3 lfs-file | |
| *.ogg lfs-file | |
| *.s3m lfs-file | |
| *.wav lfs-file | |
| *.xm lfs-file | |
| # Video formats | |
| *.mov lfs-file | |
| *.avi lfs-file | |
| *.asf lfs-file | |
| *.mpg lfs-file | |
| *.mpeg lfs-file | |
| *.mp4 lfs-file | |
| # 3D formats | |
| *.3ds lfs-file | |
| *.3dm lfs-file | |
| *.abc lfs-file | |
| *.blend lfs-file | |
| *.c4d lfs-file | |
| *.dae lfs-file | |
| *.dfx lfs-file | |
| *.FBX lfs-file | |
| *.fbx lfs-file | |
| *.glb lfs-file | |
| *.gltf lfs-file | |
| *.lwo lfs-file | |
| *.lwo2 lfs-file | |
| *.lxo lfs-file | |
| *.obj lfs-file | |
| *.ma lfs-file | |
| *.max lfs-file | |
| *.mb lfs-file | |
| # Font formats | |
| *.ttf lfs-file | |
| *.otf lfs-file | |
| # Bundles and binaries | |
| *.dll lfs-file | |
| *.exe lfs-file | |
| *.mdb lfs-file | |
| *.pdb lfs-file | |
| *.so lfs-file | |
| # Packaging | |
| *.zip lfs-file | |
| *.7z lfs-file | |
| *.gz lfs-file | |
| *.rar lfs-file | |
| *.tar lfs-file |
Would it be useful to have *.cs text diff=csharp in there?
Would it be useful to have
*.cs text diff=csharpin there?
Yea I think it makes sense. I've added it. Thank you!
Shouldn't line 17 be unityyamlmerge rather than unityamlmerge ?
@JorisVanEijden, Oh wow what a miss hehe. Well spotted! I've updated the gist accordingly. Thank you!
Might want to specify lfs for occlussion data. In my project, my OcclusionCullingData.asset file is 136MB for example which exceeds Github's 100MB limit for non lfs tracked files.
Typo on line 15, Unities should be Unity's.
@JosiahJack I've added both suggestions. Thank you!
Added glTF, an open standard (ISO/IEC) for exchanging files between 3d software and engine software.
The .glf is the binary format. The .gltf is the (readable) text format.
*.glf lfs-file
*.gltf lfs-fileShouldn't the binary format be .glb? At least when exporting with Blender it is so.
Nice catch. You are right.
Source: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#file-extensions-and-media-types
I've updated the file accordingly.
Why is the merge being unset on line 17. Is that a typo?
@AndyUrquijo I believe it was indeed a typo. I've updated it.
Some times TextMeshPro's font assets; <font_name>.asset can end up being too big.
Could a filter for assets inside a font/fonts folder be added?
Something like:
**/[Ff]ont*/**/*.asset lfs-file
(Ii'm not very versed on how the topic, so I don't know if any other attributes should be set)
I am not very well know but I think *.asmdef unity-yaml-file -linguist-generated could be changed to *.asmdef unity-yaml-file in https://gist.github.com/webbertakken/ff250a0d5e59a8aae961c2e509c07fbc#file-gitattributes-L23
@jorelosorio thank you very much for your comment! What you're suggesting would hide changes in assembly definition files in pull requests. Is that what you would argue should happen?
Rationale from my side: When I added it I thought it would be helpful to see changes in assembly definitions as they can easily break builds for other people locally or in CI - and therefor might be important to manually review.
@webbertakken your rationale makes sense, thanks for the explanation.
I made an update for this line :
*OcclusionCullingData.asset lfs-file
And added that one after
*LightingData.asset lfs-file
I have had a project with a 120mo LightingData.asset file.
Does that make sense ?
@Gil-1 thank you very much for your comment! I've adopted your changes in this gist.
Vfvbg
If you've found your way here, you may want to consider using this template as a base instead: https://github.com/gitattributes/gitattributes/blob/master/Unity.gitattributes
It handles things a bit more tidily, especially for projects with lots of different users using different tool sets and with different local git configs.
Thanks for sharing @Bomadeno.
Keep in mind that this gist is actually battle tested in CI workflows including GameCI setups.
We were using macros and CI specific settings years before they did.
especially for projects with lots of different users using different tool sets and with different local git configs.
I have no idea what this means exactly. But I'd be happy to update this battle tested CI version with any suggestions you might have to handle things a bit more tidily as you suggest.
I'd say the two templates are really close. Definitely no slight upon this gist, it was our start point. As a resuilt it took me a while to be sure what mattered in our case: the Unity.gitattributes template sets unity-yaml files to eol=lf. By default, Unity uses LF as line ending on yaml files (I couldn't find any official Unity word on this, but my experiments suggest this is true across all platforms). This doesn't matter so much on CI, because CI rarely modifies and commits (or modifies at all). For team members with the different configs this can quickly lead to churn on yaml files, with messy looking workspaces when they have no actual change in those assets.
What I meant by different configs... over time a project with a fair few people, using different setups (OSes, command line tools, git installation, "other" git tools like source tree or gitkraken) is that people are left with all flavors of core.autocrlf settings, and with diff tools that sometimes helped them see changes, and sometimes did not. If a dev team has consistent basic settings, this probably wouldn't be an issue.
Anyway, to resolve this I cautiously suggest adding the eol=lf:
[attr]unity-yaml-file -text merge=unityyamlmerge linguist-generated eol=lf
Cautiously, because after this it may also be recommendable to run renormalize to prevent endless churn, and renormalizing is not always funtimes.
Please feel free to add a comment if you're missing anything here.