如何为git准备一个Unity项目? [英] How to prepare a Unity project for git?
问题描述
准备Unity项目以提交git存储库所需的步骤如下: GitHub的?我不想存储不必要的文件(特别是临时文件并尽可能避免使用二进制格式)。
在Unity Editor中打开您的项目并:
- $在 Unity →首选项→包裹→存储库中启用外部选项 (仅适用于Unity ver< 4.5)
- 在编辑中切换到可见元文件→ / strong>→编辑器→版本控制模式 切换到强制文字 →项目设置→编辑器→资产序列化模式 文件菜单。
- 退出Unity,然后删除项目中的库和 Temp 目录目录。您可以删除所有内容,但需要保留资产和 ProjectSettings 目录。 你已经在线创建了空的git回购(例如github.com),现在是时候上传你的代码了。打开命令提示符并按照以下步骤操作:
- Enable External option in Unity → Preferences → Packages → Repository (only if Unity ver < 4.5)
- Switch to Visible Meta Files in Edit → Project Settings → Editor → Version Control Mode
- Switch to Force Text in Edit → Project Settings → Editor → Asset Serialization Mode
- Save Scene and Project from File menu.
- Quit Unity and then you can delete the Library and Temp directory in the project directory. You can delete everything but keep the Assets and ProjectSettings directory.
cd到/ your / unity / project /文件夹
git init
$ b $ git add *
git commit -m第一次提交
git remote add origin git@github.com:username /project.git
git push -u原始大师
您现在应该按住Option或Left Alt键打开Unity项目。这将迫使Unity重新创建库目录(这一步可能不是必须的,因为即使您没有按住任何键,我仍然看到Unity重新创建库目录)。
最后让git忽略Library和Temp目录,以便它们不会被推送到服务器。将它们添加到.gitignore文件并将忽略推送到服务器。请记住,您只会提交Assets和ProjectSettings目录。
这是我自己的Unity项目的.gitignore配方:
#===============#
#Unity生成#
#====== =========#
Temp /
对象/
UnityGenerated /
库/
资产/ AssetStoreTools *
#=====================================#
#Visual Studio / MonoDevelop生成#
#=====================================#
ExportedObj /
* .svd
* .userprefs
* .csproj
* .pidb
* .suo
* .sln
* .user
* .unityproj
* .booproj
#============#
#操作系统生成#
#=== =========#
.DS_Store
.DS_Store?
._ *
.Spotlight-V100
。粉碎
图标?
ehthumbs.db
Thumbs.db
What are the steps necessary to prepare a Unity project for committing to a git repository eg. github? I don't want to store unnecessary files (specially temp files and avoid binary formats as much as possible).
On the Unity Editor open your project and:
If you already created your empty git repo on-line (eg. github.com) now it's time to upload your code. Open a command prompt and follow the next steps:
cd to/your/unity/project/folder
git init
git add *
git commit -m "First commit"
git remote add origin git@github.com:username/project.git
git push -u origin master
You should now open your Unity project while holding down the Option or the Left Alt key. This will force Unity to recreate the Library directory (this step might not be necessary since I've seen Unity recreating the Library directory even if you don't hold down any key).
Finally have git ignore the Library and Temp directories so that they won’t be pushed to the server. Add them to the .gitignore file and push the ignore to the server. Remember that you'll only commit the Assets and ProjectSettings directories.
And here's my own .gitignore recipe for my Unity projects:
# =============== #
# Unity generated #
# =============== #
Temp/
Obj/
UnityGenerated/
Library/
Assets/AssetStoreTools*
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj
# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
这篇关于如何为git准备一个Unity项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!