Unity Git - 忽略库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32783295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:24:52  来源:igfitidea点击:

Unity Git - Ignore Library

gitunity3dmetadataconflictgitignore

提问by CosmicSeizure

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.

过去两天,我们一直在尝试在 Mac 和 PC 之间的项目中使用 Unity 设置 Git。我们让它有点工作,但我们仍然有元数据问题和 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.

我们在 .gitignore 文件中获得了整个 Library 文件夹,但由于某种原因,其中的某些文件似乎没有被忽略。

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?

知道为什么库文件夹不会被忽略文件完全忽略吗?冲突问题似乎来自于 assetDabase 文件。对于 Mac 和 PC 之间的良好工作流程有什么建议吗?

回答by Daimee MacIsaac

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

我最近发生了这种情况,发现问题是我的整个 Unity 项目都在 repo 的一个文件夹中,而 gitignore 使用的语法是

/[Ll]ibrary/

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

它只搜索与 gitignore 本身相同级别的文件夹,而

[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.

编辑:应该注意的是,如果您出于某种原因碰巧在其他地方使用该名称,则此解决方案还会导致它忽略任何其他名为 Library 的文件夹。

回答by Ajanthan Hariharan

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

即使在您将文件添加到 gitignore 之后,Git 可能仍然知道您添加的文件。

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

尝试提交您的实际更改,然后运行以下命令。

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

回答by rutter

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

强烈建议您根据本指南设置您的 Git 存储库。

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

您应该使用 Unity 的“元”文件进行资产序列化,这将允许您忽略Library版本控制中的文件夹。

The meta files include asset import settings, GUID information, and so on. This information is normally stored in the Libraryfolder, 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 Libraryis not necessarily consistent, and will cause unnecessary conflicts in version control.

元文件包括资产导入设置、GUID 信息等。此信息通常存储在Library文件夹中,每台计算机在导入资产时都会自动生成该文件夹。元文件中包含的数据很重要,并且必须在计算机之间保持一致;中的其余信息Library不一定一致,会在版本控制上造成不必要的冲突。