Skip to content

Instantly share code, notes, and snippets.

@AkhmadMax
Last active December 17, 2015 22:49
Show Gist options
  • Save AkhmadMax/5684418 to your computer and use it in GitHub Desktop.
Save AkhmadMax/5684418 to your computer and use it in GitHub Desktop.

Git And Unity 3.5

This guide has been written to serve as a reference to setting up maintaining a Git repository of a shared Unity 3.5 project. It's a culmination of official documentation articles, archived forum threads, and general experimentation.

A Note on Existing Projects

This guide has not been tested on any existing project. There's a possibility that because a scene file isn't initially tracked, it may prove to be incompatible, or it is assigned a metadata file and tracked by Unity like any other file.


Setting Up The Initial Repository

You don't need to read this if you're trying to access a project that already exists. See "Forking An Existing Unity Repo" Instead

I much prefer using Github for Mac in order to manage repositories. Until there is a native feeling Windows Client I am never comfortable.

Create A New Unity Project

The directory you create this is in is not final. It simply allows us to create the initial layout of files Unity would expect.

Turn On Version Control

With the main Unity editor open, go to Edit > Project Settings > Editor

You'll see the Editor Settings Inspector panel. Set the Version Control Mode to Meta Files This signals Unity to keep meta files of each asset store in the project. As of Unity 3.5, project files are organised to be much more Version Control friendly, and Unity Free users can now take advantage of using external Version Control systems like their non-Asset Server Pro brethren.

After doing this. Close Unity.

Prepare The Project Folder

Now Navigate to the Project's folder.

Inside this folder, you should see a Library folder. Delete The Library folder.

If you also see a Temp folder in the Project, delete this too.

Turn the Project Into A Repo

Open Github for Mac, so that you can see the main "My Repositories" Screen.

Now click and drag the whole project folder into The New Repository area (located at the bottom of the left-hand sidebar)

A pop up will appear, stating that the folder is not yet set up as a git repository. This is completely true, and we do want to create a new git repository here. So click Yes.

the folder should now appear inside your My Repositories area of Github for Mac, but it has not yet been pushed to Github online. We'll get to that after a bit of housekeeping.

Double click the newly created repository to view it. There isn't much there right now.

Go into Settings and edit the .gitignore file (the text field for it should currently be blank)

You can use markdown similar to that of Github to comment on things in your .gitignore file. Use hash to comment lines.

For our .gitignore we want to ignore the Library folder, the Temp folder, and any MonoDevelop project management files that find their way in there as well. You might want to add other file types (such as .exe's or Thumbs.db too)

# Ignore The following directories / file extensions
Library
Temp

# Ignore the following file extensions
*.exe
*.vcproject
*.sln
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment