14

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

3 Answers 3

28

I recently had this happen to me and found that the issue was that I had my entire Unity project in a folder in the repo, and the gitignore was using the syntax of

/[Ll]ibrary/

which only searches folders at the same level as the gitignore itself, whereas

[Ll]ibrary/

without the leading / searches all subfolders as well. Removing the leading / led it to properly ignore the Library. Hope this helps!

EDIT: It should be noted that this solution will also cause it to ignore any other folders named Library, if you happen to be using that name elsewhere for some reason.

2
  • 2
    This solved my issue, but I have to modify the .gitignore file adding the specific Unity path, like /GameName/[Ll]ibrary and stuff. Also, I created the file in the project root and running the git rm -r --cached . command
    – franco
    Commented Mar 18, 2022 at 15:18
  • 1
    The above comment is the correct method and should be made into an answer and accepted as the correct answer.
    – David
    Commented Nov 4, 2023 at 8:45
13

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"
1
  • 2
    hi, this unfortunately didnt work for me, actualy it messed up whole Unity ( crashing on every start up ) and i had to roll back to old commit. Commented Sep 25, 2015 at 16:33
4

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.