I want my repository to only have the project files that Unity needs for the project to load properly and so I can work with it properly. Like, for example, in my Project folder there is the folder ‘Build’. I don’t need that to be able to continue working with the project. I also don’t think I need the ‘Temp’ folder, right?
Well, I created a completely new Unity project to see what is there from the start - the folders ‘Library’, ‘Assets’ and ‘ProjectSettings’. The problem is that the ‘Library’ folder has files that change often and I don’t think the Project really needs them to work (like there’s a metadata and cache subfolder that constantly changes inside of it).
So can you guys give me a tip or two on how to make sure that I only commit files that the project needs and don’t have to commit some useless temp files every time I commit, without actually needing them.
Unity say http://docs.unity3d.com/Documentation/Manual/ExternalVersionControlSystemSupport.html
“When checking the project into a version control system, you should add the Assets and the ProjectSettings directories to the system. The Library directory should be completely ignored - when using external version control, it’s only a local cache of imported assets.”
For now I’m just using a .gitignore of:
#.gitignore file
Temp/*
Library/*
Build/*
#Un-ignore these specific files
#ignoring pidb, they are just code completion caching data according to:
#This is the git ignore file used in Duck Hunted #Note that ! negates an ignore. We ignore everything in Library then #un-ignore the metadata folder and some specific files #Use at your own risk, this may totally destroy your project, but it worked for us
#NOTE: this will cause your collaborators to re-import assets periodically
Temp/*
Library/*
Build/* #Un-ignore these specific files
!Library/*.asset
!Library/AssetImportState
!Library/AssetVersioning.db
!Library/BuildPlayer.prefs
!Library/ScriptMapper
!Library/assetservercachev3
!Library/expandedItems
!Library/guidmapper
!Library/unity default resources
!Library/unity editor resources
!Library/metadata/
#ignoring pidb, they are just code completion caching data according to:
You can use the Unity .gitignore preset from Github.
Since I don’t want to have binary files under version control, I wrote my own backup tool. You can specify which filetypes you want backed up and not under version control in your .gitignore file. The tool then parses your .gitignore file and recursively searches your asset directory to search for files of the specified types. It copies all files, including their metafiles and those of the directories over to another directory and - if you wish - compresses it into a zip archive.
Here’s my .gitignore file:
This file makes git ignore wav, ogg, mp3, tga and psd files and backs them up using my tool instead.
Since the UBB folder where the backups are created isn’t actually a folder on my machine, but a symlink, all backups are automatically synched with my Google Drive. Quite convenient.