Skip to content

Instantly share code, notes, and snippets.

@teocomi
Created September 13, 2016 15:01
Show Gist options
  • Star 65 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save teocomi/fbd014c26c63c7c1055d025e2339dea7 to your computer and use it in GitHub Desktop.
Save teocomi/fbd014c26c63c7c1055d025e2339dea7 to your computer and use it in GitHub Desktop.
Gitignore for Unity projects
# =============== #
# Unity generated #
# =============== #
[Tt]emp/
[Oo]bj/
[Bb]uild
/[Bb]uilds/
/[Ll]ibrary/
sysinfo.txt
*.stackdump
/Assets/AssetStoreTools*
*.apk
*.unitypackage
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
[Ee]xported[Oo]bj/
.vs/
/*.userprefs
/*.csproj
/*.pidb
*.pidb.meta
/*.suo
/*.sln*
/*.user
/*.unityproj
/*.booproj
.consulo/
/*.tmp
/*.svd
# ============ #
# OS generated #
# ============ #
.DS_Store*
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
[Tt]humbs.db
[Dd]esktop.ini
Corridor/Library/ShaderCache/
Corridor/Library/metadata/
@nikhilsinha
Copy link

Why are .sln and .csproj files in this file? Aren't those needed for Visual Studio?

@Arrekin
Copy link

Arrekin commented May 13, 2017

Unity can generate those files so they are not necessary,

@jwvanderbeck
Copy link

I'm not so sure about excluding the sln honestly. Especially today. In older versions of Unity sure, it would wipe them out and rebuild them every time anyway so no big deal. But today Unity seems to be getting better about not doing that, and the direction Visual Studio is going, especially with NuGet, I think the sln is going to become more important.

@dylanh724
Copy link

Is this still valid for July 2017?

@danielson317
Copy link

Just tried this out. Without the project file it opens the project in a new unsaved scene when opened on a new computer. So I had to select my default scene and all seemed to work from there. Seems like this still works as of August 2017.

@dimkir
Copy link

dimkir commented Nov 13, 2017

Removing .sln files makes me cringe..

But a more practical question would be: upon which events Unity will regenerate .sln files? Also where are dependencies and project prefs kept? (eg which .cs files are "included into project" and which once are "not included"?) Trying to wrap my head around inner workings of the Unity<>VS interchange...

@dimkir
Copy link

dimkir commented Nov 13, 2017

also why .unityproj is not necessary?

Which is the "main" unity project file then?

@Thaina
Copy link

Thaina commented Nov 22, 2018

@dimkir I think .unityproj is actually .unityscriptproj which is just an equivalence to .csproj

The actual project settings for unity would be some files in ProjectSettings folder

@Salzian
Copy link

Salzian commented Nov 30, 2018

Removing .sln files makes me cringe..

It's perfectly ok to do. Unity generates the .sln and .csproj on it's own.

Also where are dependencies and project prefs kept?

Dependencies are stored in the .meta files.

@ElieUbogi
Copy link

so the gitignore is definitly ok?

@Giorgi07
Copy link

Yeah it works properly

@pascaldisse
Copy link

pascaldisse commented Mar 14, 2019

Please remove Icon? from the .gitignore!
The way this is set up, it will ignore all files that include Icon followed by a letter. For example, I had a folder called Icons which was completely ignored in my repo.

@dangpzanco
Copy link

why not just use the github provided one? https://github.com/github/gitignore/blob/master/Unity.gitignore

@Ombrezz
Copy link

Ombrezz commented Mar 6, 2020

why not just use the github provided one? https://github.com/github/gitignore/blob/master/Unity.gitignore

Because the official one assumes that your Unity project's root is the same one as your GitHub project, however it's better practice to put the Unity project inside a sub folder, this .gitignore allows you to do that.

Copy link

ghost commented Mar 12, 2020

Because the official one assumes that your Unity project's root is the same one as your GitHub project, however it's better practice to put the Unity project inside a sub folder, this .gitignore allows you to do that.

I had the same problem. You can either use */[Tt]emp/ */[Ll]ibrary/ */[Oo]bj/ and so on, but this would exclude any folders called temp. To solve this you could use the slightly messy solution of /SubFolder/[Tt]emp/ /SubFolder/[Ll]ibrary/ /SubFolder/[Oo]bj/ and so on if your unity project was in repository/SubFolder/.

@turbits
Copy link

turbits commented Jun 2, 2020

No need for modifying anything, just add a .gitignore file to any subdirectory you want and it will just work™.

@Ivan02q
Copy link

Ivan02q commented Oct 2, 2020

If you wanna share only assets files with you Team. This code if good for you.
Unity Collab shares only 4 files on there Collab. Assets, Project Settings, Packages and .collabIgnore (Git Ignore file) and that's it. You don't need any other files to work normally with team. Unity will build on your PC, Mac or whatever other files.

@halivudestevez
Copy link

AFAIK Unity does not need sln, prj. Unity uses all the files that in the folder and its subfolder.
(but I'm new to Unity, I may error)

Copy link

ghost commented Jan 8, 2021

This ignores tracking the .sln @halivudestevez.

@Kurasami
Copy link

Kurasami commented Feb 6, 2021

.vsconfig could be added too, which is created by Visual Studio in the project root DIR.

@njelly
Copy link

njelly commented May 4, 2022

UserSettings/ should be added

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