14 Feb 13
This article will go over the basics of setting up Unity to use source-control and setting up your first project
Telling Unity you want to use source-control
Within Unity, press Edit > Project Settings > Editor. In your inspector window you will see the Editor Settings for your project, under “Version Control” set the mode to Meta Files.
This will tell Unity to generate a small file for each object in your project (everything; Scripts, Prefabs, Textures, you name it, it metas it). Now, when an asset is modified in the editor, only the asset and it’s associated meta file will report changes, instead of the entire Library folder.
And then Asset Serialization, set it’s mode to “Force Text”. This will output Unity levels as an YAML document instead of a binary file (Pro Only).
Setting up the .gitignore
Unity generates some files that GIT wouldn’t need, for instance the Library folder. This contains GUID’s for each asset within the project, it’s normally packed with hundreds of files that can confuse GIT and lead to merge issues later on. To solve this we simple ignore it!
In the root of your project that you want to source control create a new file named “.gitignore” (Depending on your OS, this file may be hidden so you will need to show hidden files).
Within this file type:
.DS_Store Library Temp *.csproj *.pidb *.unityproj *.sln *.userprefs
Updated, thanks @tjheuvel
@dgoodayle You can use wildcards in .gitignore, for example: “*.csproj *.sln *.suo” would ignore all files ending with that extension.
— Tijmen vd Heuvel (@tjheuvel) February 14, 2013
Obviously replacing “[Your_Project_Name_Here]” with your project folder name..
Your first commit
Now you are ready to commit your project to your GIT server (I recommend BitBucket.org for this..). Open up your console and type:
cd <project path> git init git add . git commit -m "[Initial project setup]" git clone --bare . <repository location> git remote add public <repository location>
Change the repository location to the URL of your GIT repository and you should now be done. Well done you’ve got your Unity GIT repo setup.