This quick post documents how I typically set up a Unity project when working with external version control. Though it focuses on using Git or Mercurial via SourceTree, the principles can be applied to other version control tools.

  1. Using SourceTree (or github.com, bitbucket.org, etc.), create your remote repository and clone it to a local directory
  2. Open Unity and create a new project inside your local repository directory
  3. In Unity, go to Edit → Project Settings → Editor and configure the following:

    • Under Version Control, set Mode to Visible Meta Files
    • Under Asset Serialization, set Mode to Force Text
  4. Unity really only needs the Assets and ProjectSettings folders found in your project directory. All other files and folders – Assembly-CSharp.csprojLibrary, and Temp for instance – can be generated. Therefore, in SourceTree you can go to Repository → Repository Settings → Advanced and edit your ignore file to contain the following, adjusting as needed:

    # =============== #
    # Unity generated #
    # =============== #
    Temp/
    Library/
    
    # ===================================== #
    # Visual Studio / MonoDevelop generated #
    # ===================================== #
    ExportedObj/
    obj/
    *.svd
    *.userprefs
    *.csproj
    *.pidb
    *.suo
    *.sln
    *.user
    *.unityproj
    *.booproj
    
    # ============ #
    # OS generated #
    # ============ #
    .DS_Store
    .DS_Store?
    ._*
    .Spotlight-V100
    .Trashes
    ehthumbs.db
    Thumbs.db
    

This should be enough to get you started using Unity with external version control. You can test out your configuration by pushing your configured project to your repository and re-cloning into a new directory. If the project opens correctly from there, you’re likely in good shape!


unity git version control
PREV NEXT