Skip to content

Instantly share code, notes, and snippets.

@kleber-swf
Last active January 20, 2023 00:21
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save kleber-swf/6e62de2ed95cd2c0f2de to your computer and use it in GitHub Desktop.
Save kleber-swf/6e62de2ed95cd2c0f2de to your computer and use it in GitHub Desktop.
Git ignore for Unity Projects
# =============== #
# Unity generated #
# =============== #
[Tt]emp/
[Oo]bj/
[Bb]uild
/[Ll]ibrary/
/[Ll]ogs/
sysinfo.txt
*.stackdump
# ============================================= #
# Visual Studio / MonoDevelop / Rider generated #
# ============================================= #
[Ee]xported[Oo]bj/
.vs/
/*.userprefs
/*.csproj
/*.pidb
/*.suo
/*.sln*
/*.user
/*.unityproj
/*.booproj
/.idea*/
# ============ #
# OS generated #
# ============ #
.DS_Store*
._*
.Spotlight-V100
.Trashes
ehthumbs.db
[Tt]humbs.db
[Dd]esktop.ini
@kleber-swf
Copy link
Author

Definitive .gitignore for Unity projects
More info at: http://kleber-swf.com/the-definitive-gitignore-for-unity-projects/

@kleber-swf
Copy link
Author

Updated to support the new Unity 5.2 Visual Studio Integration

@puzzlekings
Copy link

That's really cool - many thanks!

@VoodaGod
Copy link

thanks!

@laszlar
Copy link

laszlar commented Mar 23, 2016

I know this is kinda older, but thank you for doing this! The standard Unity ignore file on GitHub doesn't include the OS generated stuff. I wonder if this will include Desktop.ini?

@kleber-swf
Copy link
Author

@laszlar: Their rules don't allow to put SO files. The reason is that you should have a global gitignore file with your system's globally ignored files. Which is good, but it's not guaranteed that all of your developers have this setup, specially when you work on a big team remotely. And yes! I put the Desktop.ini as you suggested. Thanks!

@Zebrakiller
Copy link

What kind of file do I make?

@leonidumanskiy
Copy link

"Icon" rule is the dumbest thing ever. We spent 30 minutes trying to understand why our Icons are not getting commited.

@njt1982
Copy link

njt1982 commented Jun 27, 2016

Just had the same issue as @leonidumanskiy - An entire folder of icons missing from my project repo. Lucky I noticed before I lost anything.

@kleber-swf
Copy link
Author

Sorry for that :/ This was for some OSX folders.
I removed the Icons/ rule and added Rider .idea* rule

@MiraiTunga
Copy link

@kleber-swf is this supposed to ignore everything in the library folder ?

Still getting paths like (see bellow) being tracked in source tree

\UnityProject\Library\metadata\cb\cb62af8299528774697e1e79af2e473d

@kleber-swf
Copy link
Author

That's because you have your project inside a "UnityProject" folder. This .gitignore assumes you have all your project files in the root (where the .ignore itself lies). This is done by the / at the beginning of the line /[Ll]ibrary and it's there because you may have another Library folder in your project that you want to version control.

Basically you have two options to solve this problem:

  1. move .gitinore file to your "UnityProject"
  2. remove the / from the /[Ll]ibrary line. Make sure you'll never have a "Library" folder inside your project thou

https://git-scm.com/docs/gitignore

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