一个 repo 中的不同 unity 项目,并希望 gitignore 忽略所有大容量文件夹
different unity projects in one repo and want gitignore to ignore all high size volume folders
我有一个文件夹,用于存放我所有不同的游戏,每个游戏都有自己的 "Assets", "Library", "Logs"
等文件夹。
以前,当我只想上传 1 个项目到 GitHub 时,我选择了 .gitignore
Unity,它会自动忽略那些不需要上传的大文件。
现在我在 1 个文件夹中有多个项目,我想将它们全部上传到 1 个存储库中,而且,我希望我的 .gitignore
像以前那样忽略每个目录中所有不必要的文件仅适用于 1 个 Unity 游戏。
我的.gitigonore
现在是这样的:
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
# Visual Studio cache directory .vs/
# Autogenerated VS/MD/Consulo solution and project files ExportedObj/ .consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
# Unity3D Generated File On Crash Reports sysinfo.txt
# Builds
*.apk
*.unitypackage
为了实现我想要发生的事情,我应该改变什么?
顺便说一句,我是 git 的新手,我很确定我的问题有一个非常简单的答案。
但是我在网上找不到它!
选项 A - 子模块
您可以查看 SubModules 并拥有一个类似
的存储库
- 主存储库
- 应用 1 - 子模块
- 应用 2 - 子模块
每个 SubModule 都会带来自己的 .gitignore
,适用于其相应的根文件夹。
如果您有一个主应用程序,然后在该主应用程序中使用多个实际的功能模块,这最有意义。
选项 B - **
路径通配符
只需调整 .gitignore
即可忽略 任何 具有相应名称的文件夹,如
**/[Ll]ibrary/
**/[Tt]emp/
**/[Oo]bj/
**/[Bb]uild/
**/[Bb]uilds/
**/Assets/AssetStoreTools*
Two consecutive asterisks ("**"
) in patterns matched against full pathname may have special meaning:
- A leading
"**"
followed by a slash means match in all directories. For example, "**/foo"
matches file or directory "foo"
anywhere, the same as pattern "foo"
. "**/foo/bar"
matches file or directory "bar"
anywhere that is directly under a directory "foo"
.
这在您处于(例如)的情况下最有意义。处理一个更大的项目,实际上只包含完全独立的不同 Unity 项目。
不过要小心:如果你现在有一个像 Assets/Models/Obj/...
这样的文件夹,这个文件夹将被忽略 ;)
为避免这种情况,您可以再次 not 忽略文件夹,如果它们在 Assets
文件夹内,例如
!**/Assets/**/[Ll]ibrary/
!**/Assets/**/[Tt]emp/
!**/Assets/**/[Oo]bj/
!**/Assets/**/[Bb]uild/
!**/Assets/**/[Bb]uilds/
我有一个文件夹,用于存放我所有不同的游戏,每个游戏都有自己的 "Assets", "Library", "Logs"
等文件夹。
以前,当我只想上传 1 个项目到 GitHub 时,我选择了 .gitignore
Unity,它会自动忽略那些不需要上传的大文件。
现在我在 1 个文件夹中有多个项目,我想将它们全部上传到 1 个存储库中,而且,我希望我的 .gitignore
像以前那样忽略每个目录中所有不必要的文件仅适用于 1 个 Unity 游戏。
我的.gitigonore
现在是这样的:
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
# Visual Studio cache directory .vs/
# Autogenerated VS/MD/Consulo solution and project files ExportedObj/ .consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
# Unity3D Generated File On Crash Reports sysinfo.txt
# Builds
*.apk
*.unitypackage
为了实现我想要发生的事情,我应该改变什么?
顺便说一句,我是 git 的新手,我很确定我的问题有一个非常简单的答案。
但是我在网上找不到它!
选项 A - 子模块
您可以查看 SubModules 并拥有一个类似
的存储库- 主存储库
- 应用 1 - 子模块
- 应用 2 - 子模块
每个 SubModule 都会带来自己的 .gitignore
,适用于其相应的根文件夹。
如果您有一个主应用程序,然后在该主应用程序中使用多个实际的功能模块,这最有意义。
选项 B - **
路径通配符
只需调整 .gitignore
即可忽略 任何 具有相应名称的文件夹,如
**/[Ll]ibrary/
**/[Tt]emp/
**/[Oo]bj/
**/[Bb]uild/
**/[Bb]uilds/
**/Assets/AssetStoreTools*
Two consecutive asterisks (
"**"
) in patterns matched against full pathname may have special meaning:
- A leading
"**"
followed by a slash means match in all directories. For example,"**/foo"
matches file or directory"foo"
anywhere, the same as pattern"foo"
."**/foo/bar"
matches file or directory"bar"
anywhere that is directly under a directory"foo"
.
这在您处于(例如)的情况下最有意义。处理一个更大的项目,实际上只包含完全独立的不同 Unity 项目。
不过要小心:如果你现在有一个像 Assets/Models/Obj/...
这样的文件夹,这个文件夹将被忽略 ;)
为避免这种情况,您可以再次 not 忽略文件夹,如果它们在 Assets
文件夹内,例如
!**/Assets/**/[Ll]ibrary/
!**/Assets/**/[Tt]emp/
!**/Assets/**/[Oo]bj/
!**/Assets/**/[Bb]uild/
!**/Assets/**/[Bb]uilds/