Setting Up Version Control in Unity3D (For Free)

Warning: This isn’t an explanation post about theory, this is a post about a series of steps which you can follow to make sure to setting up a Version Control in a Unity3D project/game.

This configuration works in OS X and Windows.


Setting up Version Control

  1. Download latest Unity’s version.
  2. Open or create a Unity project:
    1. Select Edit -> Project Settings -> Editor
    2. Set Version Control Mode to Visible Meta Files

      Setting the Version Control Mode
      Setting the Version Control Mode
  3. Download and install Mercurial and SourceTree.
  4. Open SourceTree and Create a local repository.

    Create Local Repository
    Create Local Repository
  5. Selecting Destination Path and Type.
    Selecting Destination Path and Type.

    In Destination Path field you have to select the root folder of your project/game (I mean the folder with the Assets, Library, Project Settings and Temp folders), also you have to set the Repository Type to Mercurial.

  6. Open the local repository you’ve created (doble-click in the name).

    Open the Local Repository
    Open the Local Repository
  7. Select Repository -> Repository Settings…

    Selecting Repository Settings
    Selecting Repository Settings
  8. We aren’t interested in all the project files, therefore we should edit the “.hgignore” file. To do it we have to select Advanced tab, and then select edit in the field called Repository-specific ignore list.

    Editing ".hgignore" file
    Editing “.hgignore” file
  9. Write the following in the “.hgignore” file and Save it:
  10. syntax: glob
    Library
    Temp
    *.pidb
    *.sln
    *.userprefs
    *.csprog
    *.orig
    
    This allows you to ignore some files (you can include any files you don't want to track in ".hgignore")."
  11. Now you have to do the first commit of the repository:
    1. Check the option of Pending Files.
    2. Write a message to commit.
    3. Press the commit button.

      Doing the first commit
      Doing the first commit
  12. You will notice that the Push button have the number one, DON’T touch it yet. 

    Push Button
    Push Button
  13. Create a user account in Bitbucket:
    1. Create a new Repository.
    2. Select Clone and Copy the URL (from http).
      Creating New Repository
      Creating New Repository

      Copying the URL
      Copying the URL
  14. In SourceTree select Repository -> Repository Settings, and in the Remotes Tab you have to click on Add button.

    Clicking Add Button
    Clicking Add Button
  15. Paste the repository URL you’ve copied from Bitbucket repository into the URL/Path field.

    Pasting Repository URL
    Pasting Repository URL int URL/Path field
  16. Your Remotes tab have to looks like this picture.

    Remotes Tab
    Remotes Tab
  17. So now you have to Push the Commit to the repository, so click on Push Button.

    Pushing the first Commit to Repository
    Pushing the first Commit to Repository
  18. Your SourceTree should looks like this picture.

    First commit made on Repository
    First commit made on Repository

Inviting Users to the Repository

If you are working with a team and want to share the repository:

  1. From the Bitbucket repository, you have to invite users to the repository (with their Username or Email address).
  2. The user has to accept the invitation.
  3. In SourceTree each user has to make a Clone from URL. (Copying and pasting the URL from their Bitbucket repository)
  4. Make sure each user has the correspond credentials (the BitBucket user account must have been invited) to log in to the SourceTree repository.
  5. That’s all, ENJOY IT! 

If you have any question leave me a comment.

For more information about Version Control visit this link.


Leave a comment