13
\$\begingroup\$

I have started working on a personal project using Unity with a friend and we've set up our own source control system.

I am aware of the fact that there are many types of files, namely those that are generated locally when you build (for example, Visual Studio files) and those that are specific to your particular machine that should not be added to source control, but I'm not exactly sure what these file types are.

I don't want to exclude any generated files I should be including, such as .meta files.

Would someone be able to list all, or at least all of the common file types that should not be added to version control, specifically for a Unity project?

\$\endgroup\$

5 Answers 5

10
\$\begingroup\$

With the current version of Unity, just check in anything in the Assets folder and ProjectSettings folder. Don't check in anything under Library, or at the top level.

\$\endgroup\$
8
\$\begingroup\$

A good reference for this kind of lists is GitHub's gitignore templates. The Unity-specific list is here.

And if you feel that something is missing, make a pull request!

\$\endgroup\$
5
\$\begingroup\$

The file type is less important that the file's purpose and origin; as you said, anything that can be generated from the source files under version control (usually) has no business being included in the repository itself.

Similarly, anything user-specific, such as settings or configuration files, should be excluded.

Beyond that it's really up to you and your project.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ I suppose what I'm asking for really, is a short list of which files in a standard unity project ARE the files that get generated or are user specific. Apart from the files that I manually create I'm fairly ignorant as to which do what and come from where. \$\endgroup\$ Commented Aug 15, 2012 at 16:26
  • \$\begingroup\$ I see. I edited your question to clarify that, as the Unity bit had been removed by the time I saw it (or I just missed it). \$\endgroup\$
    – user1430
    Commented Aug 15, 2012 at 16:39
3
\$\begingroup\$

You can take a look at my Unity project, Radius, on GitHub as an example. Or checkout the Unity.gitignore file in the official GitHub gitignore repo.

There is also a nice guide by Damien Mayance on his website about Git and Unity projects

Make sure you check in your .meta files as this is what Unity uses to reference each asset. You can make them unhidden in your OS by going to Edit->Project Settings->Editor and changing Version Control to Visible Meta Files.

If you are storing your unity project in a folder called UnityProjectName, this is what your .gitignore should look like. If you just have the Unity project folder as the root of the GitHub repo, just remove the UnityProjectName/ from each path below.

.gitignore

# Ignore unneeded Unity files
# --------------------------------------------------
UnityProjectName/Temp/
UnityProjectName/obj/
UnityProjectName/Library/

UnityProjectName/*.csproj
UnityProjectName/*.unityproj
UnityProjectName/*.sln

# Ignore Custom Builds
# --------------------------------------------------
UnityProjectName/[Bb]uilds/
\$\endgroup\$
1
\$\begingroup\$

I don't know about unity but you mentioned visual studio. There you can usually exclude the bin and obj folders in the project folders (in some project types, the bin folder also stores assemblies from included projects, but I think this only applies for certain type of web projects).

Also do not check in the ".csproj.user" and ".suo" files. Those two types include user settings. If you check those in, then all user settings will be reflected on the other machines, when you update the source. This is quite annoying, as those settings are not build or project relevant but more to configure the ui, editor etc for each developers individual needs.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .