Skip to content

Instantly share code, notes, and snippets.

@nemotoo
Last active July 18, 2025 15:35
Show Gist options
  • Save nemotoo/b8a1c3a0f1225bb9231979f389fd4f3f to your computer and use it in GitHub Desktop.
Save nemotoo/b8a1c3a0f1225bb9231979f389fd4f3f to your computer and use it in GitHub Desktop.
.gitattributes for Unity3D with git-lfs
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
*.physicsMaterial2D merge=unityyamlmerge eol=lf
*.physicMaterial merge=unityyamlmerge eol=lf
*.asset merge=unityyamlmerge eol=lf
*.meta merge=unityyamlmerge eol=lf
*.controller merge=unityyamlmerge eol=lf
## git-lfs ##
#Image
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.ai filter=lfs diff=lfs merge=lfs -text
#Audio
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
#Video
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.mov filter=lfs diff=lfs merge=lfs -text
#3D Object
*.FBX filter=lfs diff=lfs merge=lfs -text
*.fbx filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text
#ETC
*.a filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
*.unitypackage filter=lfs diff=lfs merge=lfs -text
*.aif filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.rns filter=lfs diff=lfs merge=lfs -text
*.reason filter=lfs diff=lfs merge=lfs -text
*.lxo filter=lfs diff=lfs merge=lfs -text
@nemotoo
Copy link
Author

nemotoo commented Jul 17, 2025

The repository at "https://github.com/FrankNine/RepoConfig" seems to track recent Unity versions. If there are no issues, it’ll proceed with this one.

@NPatch
Copy link

NPatch commented Jul 17, 2025

I wrote a post about that .gitattributes and other Unity with git stuff here: https://franknine.github.io/posts/unity-git-en/#gitattributes

Not entirely sure I understand this one. I tried it on a new project and it basically turned EVERYTHING into LFS files. c# files, gitignore, csv files, hell even .txt files became LFS pointers. So really confused. I thought I'd goofed up the setup the first time, but same results on the second try.

I 100% agree this gist is flawed, as I stated oh boy 6 years ago? But yours seems to swing too far in the other direction unless I'm missing something.

EDIT: You know what? This is not true. I'm a lying SOB. I went back to your file again and somehow I must have gotten a corrupted copy or well I don't know what. But when I compared what I had downloaded to what was actually in your file, there were a TON of entries directly after the SQLite entry that was essentially forcing everything to be LFS and I have no idea where it came from. But it clearly isn't in your file, so.. round 3!

Just a quick reply before this gets closed. This is why I mention git check-attr. Make a dummy repo, add all kinds of files in it, and provide the gitattributes you want, commit them all locally (it's dummy we don't care, it's only local) and then just start looking into the attributes of files you want to check. If you learn how to read the git check-attr output, which is not that hard, you'll be able to debug such situations. It's such a handy tool, but not advertised enough, especially for such a known annoying thing. e.g. for .asset files, you just check the attributes and you can surmise which rule got matched and then figure out why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment