What are the necessary steps to take to prepare a Unity project for sending to the repository (git), for example, on GitHub? I do not want to store unnecessary files (especially temporary); 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 .

2 answers 2

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

  1. Select the External option option in Unity β†’ Preferences β†’ Packages β†’ Repository (only for Unity versions <4.5)
  2. Use Visible Meta Files in Edit β†’ Project Settings β†’ Editor β†’ Version Control Mode
  3. Use Force Text in Edit β†’ Project Settings β†’ Editor β†’ Asset Serialization Mode
  4. Save the scene and project from the File menu.
  5. 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 .

    • I use the following algorithm
      1. The repository is created on Bitbucket
      2. The intermediary between the Unity project and Bitbucket is the free Sourcetree program.
      3. The .gitignore file looks like this:

    Library / Temp / Obj / Build / Builds / Assets / AssetStore *

     # Autogenerated VS/MD/Consulo solution and project files ExportedOBj/ .consulo/ *.csproj *.unityprof *.sin *.suo *.tmp *.user *.userprefs *.pidb *.booproj *.svd *.pdb # Unity3D generated meta files *.pidb.meta *.meta # Unity3D Generated File On Crash Reports sysinfo.txt # Builds *.apk *.unitypackage 

    The project weighing 1.5 GB was loaded successfully, everything works correctly

    A source