Skip to content

Instantly share code, notes, and snippets.

@MatthewMaker
Last active April 11, 2025 20:43
Show Gist options
  • Save MatthewMaker/7d5073eac20fa6a544cd01540c63aef0 to your computer and use it in GitHub Desktop.
Save MatthewMaker/7d5073eac20fa6a544cd01540c63aef0 to your computer and use it in GitHub Desktop.
Example .gitattributes file for use with repositories which contain cross-platform Unity3D projects
# Assumptions
#
# All filetypes (file suffixes) in everyone's local filesystems will be lowercased.
# Files with uppercased letters in the suffixes will be ignored by this config.
# If we wanted to support mixed-case suffixes, we'd need to adjust this file like this:
# *.jpg *.[jJ][pP][gG]
# But doing that is harder to read ...aaAaAnD could lead to its own problems.
# For later exploration: There might be some git-hook way to mandate this at the server.
#
# exceptions made: TGA FBX JPG TTF PNG XML
#
# In general, everyone will avoid committing filenames and paths that differ only in capitalization.
# (If you do need to correct an improperly-cased file, some shenanigans will be necessary.)
#
# Notes
# This config can use "macros" that you define with "[attr]" followed by the configuration line that
# it should be replaced by/considered the same as.
# Resources:
# - https://github.com/NYUGameCenter/Unity-Git-Config
# - https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# - http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
# - https://git-scm.com/docs/gitattributes
#
# - https://help.github.com/articles/dealing-with-line-endings/
# - https://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/
# - https://www.edwardthomson.com/blog/git_for_windows_line_endings.html
# - https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
# Set the default line-ending normalization behavior, in case people don't have core.autocrlf set.
# * text=auto
# Or, aggressively DON'T mess with line endings, in the case of a repo that already has files in it
# that you don't have time to force everyone to run git renormalizaion and have merge conflicts.
* -text
# Source code and their preferred endings
*.cs diff=csharp text
*.go text eol=lf
*.java text
*.js text
*.json text linguist-language=JSON-with-Comments
*.md text
*.py text eol=lf filter=tabspace
*.scala text
*.sh text eol=lf
*.gradle text
*.xml text
*.XML text
*.bat text eol=crlf
*.info text
*.md text
*.inc text
*.msbuild text
# bash files not having the .sh extension
gradlew text eol=lf
# other text
makefile text
rakefile text
*.yaml text
*.yml text
*.csv text
*.sln text eol=crlf
# NPM "bin" scripts MUST have LF, or else the executable fails to run on Mac.
# This fnmatch expression only matches files in a "bin" folder and without
# a period in the filename.
/*/*/bin/+([!.]) -text
## Unity ##
# Macro: files with Unity's YAML format
# diff means that despite other settings, we *do* want to be able to see textual diffs of these
# merge=unityyamlmerge means to (attempt to) use UnityYAMLMerge for merging these files.
# ( see https://docs.unity3d.com/Manual/SmartMerge.html )
# eol=lf means that we want LF line endings on these files in the working directory, which effectively sets 'text'
[attr]unity-yaml-file diff merge=unityyamlmerge eol=lf
# Macro: files intended for storage in LFS
[attr]lfs-file filter=lfs diff=lfs merge=lfs -text
## LFS Unity files: Large, Unity-specific binary files (and/or large static text files)
*-[Nn]av[Mm]esh.asset lfs-file
*-[Tt]errain.asset lfs-file
*-[Tt]errainData.asset lfs-file
Terrain_meshes.asset lfs-file
LightingData.asset lfs-file
Rewired_Core.XML lfs-file
*.cubemap lfs-file
*.unitypackage lfs-file
# Unity .asset files that are actually JSON (not YAML)
XRSettings.asset text
# Unity YAML files (especially, we want to be able to diff .asset files!)
*.asset unity-yaml-file
*.asmdef unity-yaml-file
*.anim 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
*.physic[mM]aterial 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
# Collapse Unity-generated files on GitHub (more info: https://robots.thoughtbot.com/github-diff-supression)
# linguist-generated is a github keyword to ignore files for language statistics and hide diffs in the github UI.
*.asset linguist-generated
*.mat linguist-generated
*.meta linguist-generated
*.prefab linguist-generated
*.unity linguist-generated
# Shaders
*.shader text eol=lf
*.cginc text eol=lf
*.hlsl text eol=lf
*.compute text eol=lf
# LFS Image Files
*.exr lfs-file
*.png lfs-file
*.PNG lfs-file
*.jpg lfs-file
*.JPG lfs-file
*.jpeg lfs-file
*.tif lfs-file
*.tiff lfs-file
*.bmp lfs-file
*.eps lfs-file
*.exr lfs-file
*.tga lfs-file
*.TGA lfs-file
*.psd lfs-file
*.ai lfs-file
*.indd lfs-file
*.gif lfs-file
*.pict lfs-file
*.pdf lfs-file
*.hdr lfs-file
*.iff lfs-file
*.xcf lfs-file
*.spp lfs-file
*.afdesign lfs-file
*.dds lfs-file
# LFS Video Files
*.asf lfs-file
*.mp4 lfs-file
*.mov lfs-file
*.m4a lfs-file
*.mpg lfs-file
*.mpeg lfs-file
*.mpeg1 lfs-file
*.mpeg2 lfs-file
*.mpeg4 lfs-file
*.avi lfs-file
*.flv lfs-file
*.wmv lfs-file
*.264 lfs-file
*.h264 lfs-file
*.hvec lfs-file
*.mjpeg lfs-file
*.mjpg lfs-file
*.3gp lfs-file
*.3GP lfs-file
*.DVX lfs-file
*.dvx lfs-file
*.ogv lfs-file
*.webm lfs-file
*.xvid lfs-file
# 3D Objects
*.abc lfs-file
*.sib lfs-file
*.tbscene lfs-file
*.mlt lfs-file
*.zpr lfs-file
*.mtl text
# LFS Mesh Files
*.FBX lfs-file
*.fbx lfs-file
*.blend lfs-file
*.blend1 lfs-file
*.collada lfs-file
*.Max lfs-file
*.MAX lfs-file
*.MB lfs-file
*.MA lfs-file
*.mb lfs-file
*.ma lfs-file
*.jas lfs-file
*.c4d lfs-file
*.gLFT lfs-file
*.gltf lfs-file
*.glTF lfs-file
*.GLTF lfs-file
*.max lfs-file
*.obj lfs-file
*.lxo lfs-file
*.lwo lfs-file
*.lwo2 lfs-file
*.3dm lfs-file
*.3ds lfs-file
*.3DS lfs-file
*.dwg lfs-file
*.dxf lfs-file
*.stl lfs-file
*.dae lfs-file
*.dem lfs-file
*.ddf lfs-file
*.kmz lfs-file
*.wlr lfs-file
*.xsi lfs-file
*.ifc lfs-file
*.epx lfs-file
*.skp lfs-file
*.skb lfs-file
*.off lfs-file
*.ply lfs-file
*.sc1 lfs-file
*.ztl lfs-file
# LFS Substance Files
*.sbs lfs-file
*.sbsar lfs-file
*.sbsprs lfs-file
*.SBS lfs-file
*.SBSAR lfs-file
*.SBSPRS lfs-file
# LFS Audio Files
*.mp3 lfs-file
*.ogg lfs-file
*.wav lfs-file
*.aif lfs-file
*.aiff lfs-file
*.flac lfs-file
*.opus lfs-file
*.imp lfs-file
*.it lfs-file
*.mod lfs-file
*.xm lfs-file
*.s3m lfs-file
*.mid lfs-file
*.midi lfs-file
# LFS Music Projects
# ableton
*.als lfs-file
*.alp lfs-file
*.ask lfs-file
*.adg lfs-file
*.adv lfs-file
*.alc lfs-file
*.agr lfs-file
*.ams lfs-file
*.amxd lfs-file
# audition
*.sesx lfs-file
*.SESX lfs-file
*.ses lfs-file
*.SES lfs-file
*.cel lfs-file
*.fft lfs-file
*.flt lfs-file
# garageband
*.band lfs-file
*.BAND lfs-file
# logic
*.lxo lfs-file
*.logicx lfs-file
*.logic lfs-file
# reaper
*.RPP lfs-file
*.rpp lfs-file
*.RPP-bak lfs-file
*.rpp-bak lfs-file
# reason
*.reason lfs-file
*.rns lfs-file
# Open Interchange: omf/iff/aaf
*.omf lfs-file
*.OMF lfs-file
*.iff lfs-file
*.IFF lfs-file
*.aaf lfs-file
*.AAF lfs-file
# protools
*.ptf lfs-file
*.pts lfs-file
# WWise
.bnk lfs-file
# LFS Fonts
*.ttf lfs-file
*.TTF lfs-file
*.ttc lfs-file
*.ufo lfs-file
*.otf lfs-file
*.fnt lfs-file
*.fon lfs-file
*.fot lfs-file
*.woff lfs-file
*.woff2 lfs-file
# LFS Symbol Files
*.pdb lfs-file
# LFS Libraries
*.dll lfs-file
*.a lfs-file
*.lib lfs-file
*.dylib lfs-file
*.so lfs-file
# LFS Builds & Utilities
*.apk lfs-file
*.dmg lfs-file
*.ipa lfs-file
*.exe lfs-file
*.app lfs-file
# LFS Archives
*.zip lfs-file
*.zipx lfs-file
*.s7z lfs-file
*.jar lfs-file
*.7z lfs-file
*.zz lfs-file
*.rar lfs-file
*.ace lfs-file
*.sitx lfs-file
*.ar lfs-file
*.iso lfs-file
*.tar lfs-file
*.gz lfs-file
*.bz2 lfs-file
*.lz lfs-file
*.lzma lfs-file
*.lzh lfs-file
*.tar.gz lfs-file
*.tgz lfs-file
*.tar.Z lfs-file
*.tar.bz2 lfs-file
*.tar.lzma lfs-file
*.tlz lfs-file
*.tar.xz lfs-file
*.txz lfs-file
*.cab lfs-file
# Other
*.caffemodel lfs-file
*.mr lfs-file
# previously: all .assets are lfs
#*.asset lfs-file
#
# Exception: All of the project settings are text assets
#**/ProjectSettings/** !filter !diff !merge -text
#
#These asset files are also good as text
#SteamVR_Settings.asset !filter !diff !merge text
#AppCenterEditorPrefsSO.asset !filter !diff !merge text
#XRGeneralSettings.asset !filter !diff !merge text
# Special exceptions
Assets/_ExperienceExpression/BuiltIn/AssetBundles/Win64/04-30-2020-nothingness_rift lfs-file
Assets/Art/AssetStore/Mirza[[:space:]]Beig/Particle[[:space:]]Systems/Ultimate[[:space:]]VFX/1[[:space:]]-[[:space:]]Assets/Scenes/1[[:space:]]-[[:space:]]Ultimate[[:space:]]VFX[[:space:]](Demo).unity lfs-file
# temporary, redundant call-outs
Assets/XR/Loaders/Wave[[:space:]]XR[[:space:]]Loader.asset unity-yaml-file
Assets/XR/Settings/Wave[[:space:]]XR[[:space:]]Settings.asset unity-yaml-file
Assets/Resources/OVRBuildConfig.asset unity-yaml-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment