Saturday, February 23, 2013

Hello GitHub!

So you want to add some source control to your Unity project beyond syncing it to a Dropbox folder? Well it really couldn't be easier, and should be a no brainer for those familiar with Git.

First and foremost, you'll need to change some Editor settings in Unity.

Edit- > Project Settings -> Editor

In the Inspector window, change Version Control Mode to Visible Meta Files. Change Asset Serialization Mode to Force Text.




Then, to create a new Git repository for a Unity project, do the following from a command line. 

Note: This is all assuming you have Git installed and added to your path.

cd C:\Path\To\Your\Unity\Project\Root\Folder
git init
git add .
git commit -m "Hello Git!"

Bada bing, bada boom! That's it. I've been going the lazy (A.K.A. more productive) route and using the GitHub GUI to manage my project's local repo and pushing to GitHub. You'll want to setup a README.md and a .gitignore file as well.

My .gitignore file:

[Ll]ibrary/
[Tt]emp/
[Oo]bj/

# Autogenerated VS/MD solution and project files
*.csproj
*.unityproj
*.sln
*.mp3

One word of advice, if you have any files or assets you know you don't want to be included in your Git repo, make your life easier and setup the .gitignore files BEFORE creating your Git repo. Otherwise, it's a real pain to completely remove sensitive data from a git repo and history. The following SO post will show you how to ignore entire directories, if so you please. 

No comments:

Post a Comment