Question:
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 .
Answer:
Open your project in the Unity editor and follow these steps:
- Select External option in Unity → Preferences → Packages → Repository (only for Unity versions < 4.5)
- Use Visible Meta Files in Edit → Project Settings → Editor → Version Control Mode
- Use Force Text in Edit → Project Settings → Editor → Asset Serialization Mode
- Save the scene and project from the File menu.
- 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 #
# =============== #
Temp/
Obj/
UnityGenerated/
Library/
Assets/AssetStoreTools*
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj
# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
Translation of the answer " How to prepare a Unity project for git?" » @German .