unity3d Using Git Large File Storage (LFS) with Unity


Example

Foreword

Git can work with video game development out of the box. However the main caveat is that versioning large (>5 MB) media files can be a problem over the long term as your commit history bloats - Git simply wasn't originally built for versioning binary files.

The great news is that since mid-2015 GitHub has released a plugin for Git called Git LFS that directly deals with this problem. You can now easily and efficiently version large binary files!

Finally, this documentation is focused on the specific requirements and information necessary to ensure your Git life works well with video game development. This guide will not cover how to use Git itself.

Installing Git & Git-LFS

You have a number of options available to you as a developer and the first choice is whether to install the core Git command-line or let one of the popular Git GUI applications deal with it for you.

Option 1: Use a Git GUI Application

This is really a personal preference here as there are quite a few options in terms of Git GUI or whether to use a GUI at all. You have a number of applications to choose from, here are 3 of the more popular ones:

Once you've installed your application of choice, please google and follow instructions on how to ensure it is setup for Git-LFS. We'll be skipping this step in this guide as it is application specific.

Option 2: Install Git & Git-LFS

This is pretty simple - Install Git. Then. Install Git LFS.

Configuring Git Large File Storage on your project

If you're using the Git LFS plugin to give better support for binary files, then you'll need to set some file types to be managed by Git LFS. Add the below to your .gitattributes file in the root of your repository to support common binary files used in Unity projects:

# Image formats:
*.tga filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text

# Audio formats:
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.aiff filter=lfs diff=lfs merge=lfs -text

# 3D model formats:
*.fbx filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text

# Unity formats:
*.sbsar filter=lfs diff=lfs merge=lfs -text
*.unity filter=lfs diff=lfs merge=lfs -text

# Other binary formats
*.dll filter=lfs diff=lfs merge=lfs -text