Open your project in the Unity editor and follow these steps:
- Select the External option 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.
- Log out of 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 have already created a new empty remote git repository (for example, on GitHub), it's time to send your code. Open a command prompt and follow these steps:
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, holding down Option or the left Alt key, open your Unity project. This will force Unity to restore the Library directory (this step may not be necessary: ββI have seen Unity restore the Library directory even if you did not hold down any keys).
Finally, make git ignore the Library and Temp directories, that is, so that they are not uploaded to the server (add them to the .gitignore file). Remember that you send only the Assets and ProjectSettings directories to a remote server.
And here is my personal βrecipeβ .gitignore 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 .