How to set up a .gitignore file for Unreal Engine

Set up your Git repository properly with a proper .gitignore configuration. Download our template and learn how to customize it for your needs.

Matthäus Niedoba
December 15, 2023
4
min read
Content

A .gitignore file is a crucial component for managing your Unreal Engine project with Git. It is a set of rules that tell Git which files to exclude from version control. A .gitignore has to be configured based on the game engine you use. We also have a .gitignore template for Unity.

Why do you need a .gitignore?

Without it you would upload too many unnecessary files into your repository. Files in folders like DerivedDataCache, Intermediate, Saved, and Build are generated locally during your work and clutter up your repository if included. By excluding these from version control, your repository stays clean and efficient.

gitignore in Anchorpoint
Using a .gitignore file will remove unnecessary files from version control

Use this example and add it to your Unreal Engine project

Download this .gitignore file and paste it to the root folder of your project. When you open it, you will see a set of rules that are specific to Unreal Engine. A .gitignore file for a Unity or a Godot project will look differently.

.gitignore in your project
Paste this .gitignore file in your Unreal Engine project

Share the .gitignore file with your team

The rules in the .gitignore file should apply to everyone on your team. Therefore, the next step is to commit and push it to the repository. Afterwards, everyone should pull your commit containing the .gitignore file. In most cases, you won't need to modify it further.

pushing a gitignore
The .gitignore file needs to be pushed to your repository

Customizing your .gitignore

If you have specific requirements, you can tailor your .gitignore file accordingly. For example, some people choose to ignore the plugins folder and use Git submodules instead, while others may not. To customize, simply use a text editor to add rules. Each rule is defined by a pattern, which includes the following symbols:

Pattern Description
character.png Ignores all files that are named “character.png”
/character.png Ignores all files in the project root that are named “character.png”
*.png Ignores all PNG files
Build/ Ignores the Build folder, only if it’s in the root of your project
*/Build Ignores the Build folder only, if it’s in a subfolder
**/Build Ignores the Build folder, regardless where it is in the project. This is useful when your Git repository has a subfolder (e.g. called Unreal) where your Unreal Engine project is located.
Build/*/file.txt Ignores the file.txt if it’s inside a subfolder of the build folder. E.g. Build/something/file.txt
!*.png Include all PNG files, even if they have been ignored before
!Build/file.txt Include file.txt, even if the Build folder is ignored

By adding an exclamation mark "!", you allow files and folders to be included, even if they were previously ignored.

Adding a local (personal) .gitignore

If you need a personal .gitignore that isn't shared with the team, you can use a special file located in the hidden ".git" folder. Inside this folder, navigate to the "info" directory. Here, you'll find a file named exclude. You can modify this file using the same rules as .gitignore, but the key difference is that these rules will only apply to your local environment and won't be shared with your team.

local gitignore file
The exclude file can be opened with a text editor and adjusted with the same rules like the .gitignore file

Git for artists

Compatible with GitHub, simple enough for non coders and optimized for game development.
Learn about Anchorpoint