学习来源:https://gameinstitute.qq.com/community/detail/112722
Unity版本:v2019.3.15f
本篇学习一下一个新项目用Git上传之前需要做哪些设置修改:
- 很多文章说将 Version Control Mode 改为 Visible Meta Files,将 Asset Serialization Mode 改为 Force Text,主要目的是将2进制的项目文件设置成文本模式,这样起冲突的时候可以对比删除修改。但本版本已经默认将上述两个设置修改过来了,此处不需要做处理。
2.设置.gitignore文件内容如下,如果没有可以自己建一个,其实就是过滤了Temp、Library、.csproj等临时文件,让他们不上传,因为不同电脑的这些临时文件都会不一样,尤其是跨系统开发(mac、win)时会起冲突,直接过滤了之后使用本地生成的临时文件就行了。
也可以自己去https://www.gitignore.io/ 在这个网址里面输入unity,得到 .ignore代码。
另外注意一下.gitignore的位置和/[Ll]ibrary/这种最前面的/是否需要,不需要可以去掉。
# Created by https://www.toptal.com/developers/gitignore/api/unity
# Edit at https://www.toptal.com/developers/gitignore?templates=unity
### Unity ###
# 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/
/[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[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
# Autogenerated files
InitTestScene*.unity.meta
InitTestScene*.unity
# End of https://www.toptal.com/developers/gitignore/api/unity
嫌上面多的也可以用简版(.gitignore与Assets文件夹同级时):
Library/
Temp/
Logs/
*.csproj
*.sln
3.至于Git工具,建议用GitHub Desktop,win和pc端基本一样,这里建议大家结合码云一起使用
网友评论