'Ignoring folder meta files on version control
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:
- Is it important to version folder meta files?
- Is there a way to automatically ignore folder meta files - particularly on git or mercurial?
Solution 1:[1]
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.
Solution 2:[2]
Yes, .meta files are important. They so some useful tasks for you like keeping GUID of your files and folders so Unity can keep references even when a file/folder is renamed or relocated. See full discussion
You need to add
# Meta Files built by Visual Studio
*.meta
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Autogenerated files
InitTestScene*.unity.meta
InitTestScene*.unity
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
into your .gitignore. Then as usual, refresh your gitignore .
Since last line keeps (un-ignores) meta files that is under Assets folder, meta files of the folders inside Assets folder are not ignored.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Roberto |
| Solution 2 |
