unity3d – How to prepare a Unity project for git?


What are the mandatory steps to take to prepare a Unity project for submission to a (git) repository, such as GitHub? I do not want to store unnecessary files (especially temporary ones); I would also like to send as few binary files as possible.

Translation of the question " How to prepare a Unity project for git?" » @German .


Open your project in the Unity editor and follow these steps:

  1. Select External option in UnityPreferencesPackagesRepository (only for Unity versions < 4.5)
  2. Use Visible Meta Files in EditProject SettingsEditorVersion Control Mode
  3. Use Force Text in EditProject SettingsEditorAsset Serialization Mode
  4. Save the scene and project from the File menu.
  5. Exit Unity; you can delete the Library and Temp directories in the project directory – you can delete everything except the Assets and ProjectSettings directories.

If you've already created a new empty remote git repository (on GitHub, for example), it's time to push your code. Open a command prompt and do the following:

cd to/your/unity/project/folder
git init
git add *  
git commit -m "First commit"  
git remote add origin git@github.com:username/project.git   
git push -u origin master

Now hold down the Option or left Alt key and open your Unity project. This will force Unity to restore the Library directory (this step may not be needed: I've seen Unity restore the Library directory even if you didn't hold down any key).

Finally, make sure that git ignores the Library and Temp directories, meaning they don't get uploaded to the server (add them to the .gitignore file). Remember that you are only sending the Assets and ProjectSettings directories to the remote server.

And here is my personal .gitignore "recipe" for Unity projects (I work on a Macbook):

# =============== #
# Unity generated #
# =============== #

# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #

# ============ #
# OS generated #
# ============ #

Translation of the answer " How to prepare a Unity project for git?" » @German .

Scroll to Top