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 and go to the questions): someone creates a folder of files that will be ignored but forget to ignore the folder's meta file. Unity creates the meta file and this person adds the meta to version control. Another person gets the changesets and, since they don't have the folder, their Unity deletes the meta file and they remove the meta file from version control. Not everyone in the team understand this, so the process is perpetuated in a loop from hell.
Surprisingly this happens all the time. So, two questions:
Yes. Unity's . meta files form a critical part of your project and hence should be committed to your Version Control System.
A . meta file is created. The relationship between the Assets Folder in your Unity Project on your computer, and the Project Window within Unity. You'll notice in the image above that there are . meta files listed in the file system for each asset and folder created within the Assets folder.
A metafile is a file containing information that describes or specifies another file. Microsoft uses this term for its Windows Metafile (WMF) format.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With