Unity Git - Ignore Library

2019-08-04 14:10发布

问题:

We have been trying to setup Git with Unity past two days on our project between Mac and Pc. We got it kinda working, but we still have issues with the metadata and conflicts in Library/AssetDatabase3.

We got the whole Library folder in the .gitignore file but for some reason it seems some files in it are not ignored.

We will also get during commits huge list of metadata instead of only seeing changes on files which actually changed, there will be list of hundreds of metadata. Again coming from Library.

Any idea why Library folder doesn't get full ignored with ignore file? The issue with conflicts seems to be coming from assetDabase file. Any suggestions for good workflow between Mac and Pc?

回答1:

Even after you have added the files to your gitignore, Git may still know about the files you added.

Try committing your actual changes and then running the following command.

git rm -r --cached .
git add .
git commit -m "fixed untracked files"


回答2:

Strongly recommend that you set up your Git repo according to this guide.

You should be using Unity's "meta" files for asset serialization, which will allow you to ignore the Library folder in version control.

The meta files include asset import settings, GUID information, and so on. This information is normally stored in the Library folder, which will be automatically generated by each computer as it imports assets. The data that's included in meta files is important and must be consistent between computers; the rest of the information in Library is not necessarily consistent, and will cause unnecessary conflicts in version control.