Instantly share code, notes, and snippets.

Embed
What would you like to do?
.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
*.physicsMaterial 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
@Meh0

This comment has been minimized.

Show comment
Hide comment
@Meh0

Meh0 Oct 1, 2016

Nice one. Thank you I'll use it to start.

Meh0 commented Oct 1, 2016

Nice one. Thank you I'll use it to start.

@Meh0

This comment has been minimized.

Show comment
Hide comment
@Meh0

Meh0 Oct 2, 2016

added .cubemap & .tif to mine

Meh0 commented Oct 2, 2016

added .cubemap & .tif to mine

@evitolins

This comment has been minimized.

Show comment
Hide comment
@evitolins

evitolins Mar 6, 2017

Any opinions on LFS tracking .asset or .unity files?

evitolins commented Mar 6, 2017

Any opinions on LFS tracking .asset or .unity files?

@popenke

This comment has been minimized.

Show comment
Hide comment
@popenke

popenke Mar 25, 2017

@evitolins doesn't Unity YAML know how to handle it?

popenke commented Mar 25, 2017

@evitolins doesn't Unity YAML know how to handle it?

@angularsen

This comment has been minimized.

Show comment
Hide comment
@angularsen

angularsen May 5, 2017

I think my terrain .asset files were corrupted by git using this setup, I suspect the eol=lf part should be removed. Any similar experiences?

angularsen commented May 5, 2017

I think my terrain .asset files were corrupted by git using this setup, I suspect the eol=lf part should be removed. Any similar experiences?

@angularsen

This comment has been minimized.

Show comment
Hide comment
@angularsen

angularsen May 5, 2017

Right, I seemed to have fixed it by removing eol=lf and adding * -text at the top.

https://gist.github.com/anjdreas/7d203cc2b2077df5acd67b8c101c4efa

angularsen commented May 5, 2017

Right, I seemed to have fixed it by removing eol=lf and adding * -text at the top.

https://gist.github.com/anjdreas/7d203cc2b2077df5acd67b8c101c4efa

@jason-yak

This comment has been minimized.

Show comment
Hide comment
@jason-yak

jason-yak Sep 10, 2017

It seems like you've incorrectly specified: physicsMaterial, it should be: physicMaterial (no s). I guess the same with the 2d variant as well.

jason-yak commented Sep 10, 2017

It seems like you've incorrectly specified: physicsMaterial, it should be: physicMaterial (no s). I guess the same with the 2d variant as well.

@nickcottrell

This comment has been minimized.

Show comment
Hide comment
@nickcottrell

nickcottrell commented Nov 20, 2017

thanks!

@FullStackForger

This comment has been minimized.

Show comment
Hide comment
@FullStackForger

FullStackForger Jan 26, 2018

Thanks @jason-yak. Here is fork with updated physics -> physic along with some other configuration following this guide.

FullStackForger commented Jan 26, 2018

Thanks @jason-yak. Here is fork with updated physics -> physic along with some other configuration following this guide.

@NPatch

This comment has been minimized.

Show comment
Hide comment
@NPatch

NPatch Mar 22, 2018

I also stumbled on the terrain issue. Problem is that most .asset files in Unity are YAML but TerrainData is the only thing I know of that is binary even if you Force Text serialization. Couldn't Unity just use a different extension if it was a special case?! Oh well.

NPatch commented Mar 22, 2018

I also stumbled on the terrain issue. Problem is that most .asset files in Unity are YAML but TerrainData is the only thing I know of that is binary even if you Force Text serialization. Couldn't Unity just use a different extension if it was a special case?! Oh well.

@timdhoffmann

This comment has been minimized.

Show comment
Hide comment
@timdhoffmann

timdhoffmann Apr 9, 2018

@NPatch I was asking myself the same thing. Might be best to just stick to tracking Terrain assets in regular git?

timdhoffmann commented Apr 9, 2018

@NPatch I was asking myself the same thing. Might be best to just stick to tracking Terrain assets in regular git?

@40detectives

This comment has been minimized.

Show comment
Hide comment
@40detectives

40detectives Apr 24, 2018

@NPatch @hoffmannprojects
I can think of two solutions:

1. If only the terrain files are the .asset that are always binary ones, which I'm not 100% sure right now (after a quick search I found a couple more binaries but were on directories like Library that are not meant to be versioned), you can save all terrains in a specific path like Assets/Terrains/** (or similar). And add it to your .gitattribute file right in this order:

*.asset merge=unityyamlmerge eol=lf
/Assets/Terrains/*.asset filter=lfs diff=lfs merge=lfs -text
#only if subfolders with terrains exist:
/Assets/Terrains/**/*.asset filter=lfs diff=lfs merge=lfs -text

2. Let git guess the type of file with:

*.asset merge=unityyamlmerge text=auto

I will probably go for the first option (if you can afford that folder structure) since it's the more flexible.

40detectives commented Apr 24, 2018

@NPatch @hoffmannprojects
I can think of two solutions:

1. If only the terrain files are the .asset that are always binary ones, which I'm not 100% sure right now (after a quick search I found a couple more binaries but were on directories like Library that are not meant to be versioned), you can save all terrains in a specific path like Assets/Terrains/** (or similar). And add it to your .gitattribute file right in this order:

*.asset merge=unityyamlmerge eol=lf
/Assets/Terrains/*.asset filter=lfs diff=lfs merge=lfs -text
#only if subfolders with terrains exist:
/Assets/Terrains/**/*.asset filter=lfs diff=lfs merge=lfs -text

2. Let git guess the type of file with:

*.asset merge=unityyamlmerge text=auto

I will probably go for the first option (if you can afford that folder structure) since it's the more flexible.

@jojoblaze

This comment has been minimized.

Show comment
Hide comment
@jojoblaze

jojoblaze Aug 5, 2018

I added .exr too. Sounds correct?

jojoblaze commented Aug 5, 2018

I added .exr too. Sounds correct?

@lopespm

This comment has been minimized.

Show comment
Hide comment
@lopespm

lopespm Aug 23, 2018

LightingData.asset seems to be always binary. This should also be added as well I believe?

 LightingData.asset binary

lopespm commented Aug 23, 2018

LightingData.asset seems to be always binary. This should also be added as well I believe?

 LightingData.asset binary
@Dreaddisk

This comment has been minimized.

Show comment
Hide comment
@Dreaddisk

Dreaddisk Sep 23, 2018

Noob here, is this a better version of the Unity.gitignore or a different file?

Dreaddisk commented Sep 23, 2018

Noob here, is this a better version of the Unity.gitignore or a different file?

@debuggins

This comment has been minimized.

Show comment
Hide comment
@debuggins

debuggins Sep 27, 2018

@Dreaddisk This file is for use with Git LFS

debuggins commented Sep 27, 2018

@Dreaddisk This file is for use with Git LFS

@jacobschellenberg

This comment has been minimized.

Show comment
Hide comment
@jacobschellenberg

jacobschellenberg Oct 4, 2018

I see you're using:

*.asset merge=unityyamlmerge eol=lf

for all .asset files. But what I'm finding is that things like, /ProjectSettings/* is text, like TagsManager.asset and should be able to merge by line. So yeah, we don't want those in LFS.

On the other hand, Unity decided to use .asset for other things too, like meshes, materials, and others. Some of which are upwards of 25mb. Some of which are text (mesh/material), but others that are binary.

Is there a way to specify, if binary use lfs? Or do you really think it's okay for all .asset files to not use LFS?

jacobschellenberg commented Oct 4, 2018

I see you're using:

*.asset merge=unityyamlmerge eol=lf

for all .asset files. But what I'm finding is that things like, /ProjectSettings/* is text, like TagsManager.asset and should be able to merge by line. So yeah, we don't want those in LFS.

On the other hand, Unity decided to use .asset for other things too, like meshes, materials, and others. Some of which are upwards of 25mb. Some of which are text (mesh/material), but others that are binary.

Is there a way to specify, if binary use lfs? Or do you really think it's okay for all .asset files to not use LFS?

@40detectives

This comment has been minimized.

Show comment
Hide comment
@40detectives

40detectives Oct 8, 2018

I see you're using:

*.asset merge=unityyamlmerge eol=lf

for all .asset files. But what I'm finding is that things like, /ProjectSettings/* is text, like TagsManager.asset and should be able to merge by line. So yeah, we don't want those in LFS.

On the other hand, Unity decided to use .asset for other things too, like meshes, materials, and others. Some of which are upwards of 25mb. Some of which are text (mesh/material), but others that are binary.

Is there a way to specify, if binary use lfs? Or do you really think it's okay for all .asset files to not use LFS?

Check my previous message just a little bit above in the page.

I would probably go with the option 1, just because I do not really trust the ability of git to determine that. So you would like to identify the "*.assets" that are binaries and make some rules just for them. The most commons are terrains, not sure of any others.

40detectives commented Oct 8, 2018

I see you're using:

*.asset merge=unityyamlmerge eol=lf

for all .asset files. But what I'm finding is that things like, /ProjectSettings/* is text, like TagsManager.asset and should be able to merge by line. So yeah, we don't want those in LFS.

On the other hand, Unity decided to use .asset for other things too, like meshes, materials, and others. Some of which are upwards of 25mb. Some of which are text (mesh/material), but others that are binary.

Is there a way to specify, if binary use lfs? Or do you really think it's okay for all .asset files to not use LFS?

Check my previous message just a little bit above in the page.

I would probably go with the option 1, just because I do not really trust the ability of git to determine that. So you would like to identify the "*.assets" that are binaries and make some rules just for them. The most commons are terrains, not sure of any others.

@Domvel

This comment has been minimized.

Show comment
Hide comment
@Domvel

Domvel Oct 16, 2018

Some *.asset files are binary, others text. I also have a hybrid (text / binary) asset file with a size of 180 MB. How to handle it in .gitattributes?
*.asset filter=lfs diff=lfs merge=lfs -text?

Domvel commented Oct 16, 2018

Some *.asset files are binary, others text. I also have a hybrid (text / binary) asset file with a size of 180 MB. How to handle it in .gitattributes?
*.asset filter=lfs diff=lfs merge=lfs -text?

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