Unity .gitignore不忽略.asset文件

问题描述 投票:0回答:1

我目前正在尝试阻止对git版本控件的更改,这些更改处理某个文件夹中的.asset文件。即使我输入以下行,.asset文件及其关联的.meta文件也会添加到提交中。我什至尝试阻止该数据所在的特定文件夹,但仍会推送。我不知道giti​​gnore中的前几行是否弄乱了。

*。asset

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

# Crashlytics generated file
crashlytics-build.properties

# SongPong Specific ___CUSTOM___
*.swp
*.asset
#Ignore all .meta file
*.meta
#But not source file with postfix. which is everything but a folder
!*.*.meta

此外,如果有人使用更好/更新的gitignores来保持统一,我也将不胜感激

git unity3d gitignore
1个回答
0
投票

请记住,gitignore不会从先前的提交中神奇地删除文件。

关于为何仍添加资产的原因,我找不到问题源。根据以下行,如果您的元文件具有前缀或在/[Aa]ssets/**/内,则仍会添加它们:

!/[Aa]ssets/**/*.meta

此外,您应该始终推送与项目中文件相关联的元文件!如果您不这样做,并且有人拉该项目,那么还将在另一个项目中创建新的唯一元文件。现在,你们两个都有不匹配的元文件,这意味着您的“指针”不再同步,您将遇到缺少参考问题的情况。假设有人创建了一个预制件,并在检查员的某个公共场所引用了该预制件,然后推送了更改。您将其拉出,但对您而言引用的ID不存在,因为该文件的元文件具有不同的ID。因此,您突然会丢失参考,并且该文件不再位于该公共字段中。

© www.soinside.com 2019 - 2024. All rights reserved.