To The Point

A Tutorial In Visual Studio, Unity, and Git

Aug 03 2016

Working
After working with TFS source control and Visual Studio on Unity projects, by myself or with one team member, I appreciate the features and easy integration of TFS and Unity. However, I found branching and merging wasn't intuitive. Also, I tended not to rely on the Visual Studio Online tools, and would rather not have the tools than have them and ignore them. I decided to try Git source control with Visual Studio 2013 Community Edition and Unity 5 Personal Edition. Git, initially, could not commit while Unity was open, and wouldn't ignore any file in the local repository. The following are the steps I used to make the three tools work together. First I created a Git repository online, "HelloUnityRepo". Next step was creating a new Unity 5 project, "HelloUnity", with the Visual Studio 2013 Tools Assets Package included. In HelloUnity's project settings, Edit -> Project Settings -> Editor, I switched Version Control Mode to Visibile Meta Files. Ignoring these Unity meta files is the most important part of Git with Unity, but if the Version Control Mode is set to Hidden Meta Files, then this process is likely to become whack a mole. I saved the scene, quit Unity, deleted everything in the root of HelloUnity except the Assets and ProjectSettings directories, opened Git Bash and pushed to HelloUnityRepo/origin. I re-opened HelloUnity in Unity, then found the root in the folder explorer. I added a new text file: Temp/ Obj/ Library/ ExportedObj/ *.svd *.userprefs *.csproj *.pidb *.suo *.sln *.user *.unityproj *.booproj .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes Icon? ehthumbs.db Thumbs.db and saved it as gitignore.txt. The only strategy for saving extension-less files on Windows 8.1 I got to work was to open the console in the root and execute: "ren gitignore.txt .gitignore" I can now use Git through Visual Studio's Team Explorer while Unity is open with no erratic behavior, and no dozens of temporary or metadata files to commit.