Unity creates and deletes meta files for folders inside the Asset folder.
That can create an annoying situation when using version control (that you can skip an
The Unity docs say:
When creating new assets, make sure both the asset itself and the associated .meta file is added to version control.
For me this is reason enough to put them under version control. I see two approaches to solve the problem:
I just played around with the different git commands, the following could be useful: The git hook script shoud first check if .gitignore has changed by:
git diff-index --cached --name-only HEAD | grep ".gitignore"
Print out directory names of all newly added lines in .gitignore if they are located under the Assets folder:
git diff --cached --word-diff=plain .gitignore | grep -o -e "{+\/.*\/Assets\/.*+}" | cut -d + -f 2
Update
I just wrote such a pre-commit hook :-) See the GitHub repository git-pre-commit-hook-unity-assets for code and my blog posting about it for more details.
Add this to .gitignore
#Ignore all .meta file
*.meta
#But not source file with postfix. which is everything but a folder
!*.*.meta
This will ignore file without postfix. But that shouldn't hurt.
to include meta files along with assets, simply add the following after your exclusions:
!*.*.meta
Here is a sample of my .gitignore:
# Ignore the following files
# --------------------------
# Unity3D specific
#
**/Library/*
**/Temp/*
**/*.csproj
**/*.unityproj
**/*.sln
**/*.userprefs
**/*.pidb
# include meta files
!*.*.meta
I place this at the folder with the git repository structure, so my project structure would look similar to:
root folder /
- Unity Project/
- .gitignore
- .git/
- ProjectFolder/
- {all project related data}
hope that helps.