Skip to content

Instantly share code, notes, and snippets.

@geoffalday
Last active June 25, 2023 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoffalday/c56b94764a64bb44b6d9bc1cc8fffd75 to your computer and use it in GitHub Desktop.
Save geoffalday/c56b94764a64bb44b6d9bc1cc8fffd75 to your computer and use it in GitHub Desktop.
Setting up Unity for Git LFS

How to set up Unity to use Github and Git LFS

Instructions for Windows

  1. Install Git: https://git-scm.com/

  2. Install Git Large File Storage: https://git-lfs.github.com/

  3. Create a Github account: https://github.com/

  4. Install the Github desktop app (not required if using command line): https://desktop.github.com/

  5. Create a new Github repo on Github website and add the Unity .gitignore template

  6. Clone the new repo on local machine via File > Clone repository in Github desktop app

  7. Navigate to the local repo directory in Windows File Explorer, right click inside the directory, and select: Open Git Bash Here

  8. In the Git Bash command window, tell Git you want to use Git LFS by entering: git lfs install

  9. In the Git Bash command window, initialize a new .gitattributes file by entering: git lfs track “*.psd”

  10. Create a new Unity project in the same local repo directory

  11. Open Project Settings in Unity and make sure Editor > Asset Serialization Mode is set to Force Text

  12. Move the .gitignore file into the Unity project subdirectory

  13. Replace contents of the .gitattributes file with this:

    ## 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
    *.tif 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
    
  14. In the Github desktop app, type Initial commit in the Summary field and click the Commit to main button

  15. In the Git Bash command window, you can see the files that use Git LFS by entering: git lfs ls-files

Credits

I got tired of watching this YouTube video and decided to capture the instructions here in case the video ceases to exist.

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