Unreal Engine .gitignore and .gitattributes for Git LFS
Copy-paste .gitignore and .gitattributes files for Unreal Engine projects, and how to fix a repo that started without Git LFS.
Git wasn't made for big binary files, and an Unreal project is full of them. Without the right setup, every version of every asset stays in your repo forever. Clones get slower every week, and eventually your Git host starts rejecting pushes.
Two small files prevent all of that. Put them next to your .uproject file, ideally in your very first commit:
.gitignore
Unreal creates a few folders that it can always rebuild. Keep them out of Git, or you'll get a huge repo and conflicts on every pull:
# Generated by Unreal
Binaries/
DerivedDataCache/
Intermediate/
Saved/
# Same folders inside plugins
Plugins/**/Binaries/
Plugins/**/Intermediate/
# Visual Studio and Rider
.vs/
.idea/
*.sln
*.suo
*.VC.db
*.VC.opendbBecause Binaries/ is ignored, anyone who opens the project has to compile it first. If your artists don't have Visual Studio set up, give them editor builds from your build machine, or commit the editor binaries just for them.
.gitattributes
This file tells Git which files to hand over to Git LFS. LFS stores the actual files separately and keeps just a small pointer in your repo, so the repo itself stays small:
Here's a good starting point:
# Unreal assets
*.uasset filter=lfs diff=lfs merge=lfs -text lockable
*.umap filter=lfs diff=lfs merge=lfs -text lockable
# Art, audio, video and fonts
*.fbx filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
*.hdr filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.otf filter=lfs diff=lfs merge=lfs -textIf your project uses other big file types, like .blend files from Blender, add a line for each one.
What does lockable do? Two people can't both edit the same Blueprint or level and merge their changes afterwards, because Unreal assets can't be merged. With lockable, assets are read-only until you run git lfs lock on them, so everyone can see who's working on what.
Setting it up
Commit both files first
Before you add any assets:
git add .gitignore .gitattributes
git commit -m "Add gitignore and LFS attributes"Check that assets go to LFS
After you commit some assets:
git lfs ls-filesEvery .uasset and .umap should show up in the list. If a file is missing, its extension isn't in your .gitattributes.
Already committed assets without LFS?
Adding .gitattributes now only helps from this point on. The assets already in your history stay as regular Git files. To move them to LFS, you have to rewrite the history:
git lfs migrate import --include="*.uasset,*.umap" --everything
git push --force --allThis changes every commit in the repo. Everyone on the team needs to clone it again afterwards, and open pull requests will need to be recreated. Pick a time with your team before running it.
Watch your LFS quota
Git hosts limit how much LFS storage and download bandwidth you get, and Unreal projects use a lot of both. Every fresh clone downloads the LFS files again, including clones made by build machines. Check your host's current limits before you push a big project.
Building it automatically
With the repo set up, you can have every push turn into a packaged build. Unreal Cloud's GitHub integration does that without a build machine of your own: connect the repo, pick a platform and engine version, and every push gives you a build to download.