准备工作
- 在本机生成ssh密钥
ssh-keygen -t rsa -C "你的邮箱地址"
- 点击回车后会出现生成的密钥路径,我们直接打开密钥复制下来。
- github官网添加我们的本机密钥
进入Github官网,点击设置,选择SSH and GPG keys
- 点击new SSH key,将我们刚才在本机生成的ssh密钥放入key中,并起一个名字(Title随便填)
- 最后点击Add SSH key,之后显示成功,我们回到本机通过 ssh -T [email protected] 命令测试是否成功!
Github创建仓库
- 进入Github,右上角添加新仓库
- 填入仓库名称和仓库是否公开
创建本地git项目
- 打开我们的项目目录,右击 Open Git Bash here
- 对项目进行Git初始化 命令:git init
- 初始化成功后,创建.gitignore文件,这个文件配置这那些文件需要传到git仓库。
touch .gitignore
- 打开.gitignore文件,把下面代码粘贴进入,这是官方给出的标准Unity项目配置。
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/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/
# Recordings can get excessive in size
/[Rr]ecordings/
# 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
*.aab
*.unitypackage
*.app
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
- 之后通过git status查看当前状态
- 将文件添加至缓存区,命令行中输入
git add .
- 将缓存区的内容加到本地仓库中
git commit -m "提交信息备注"
本地git项目与Github仓库进行远程连接
- 本地仓库和Git仓库进行连接
git remote add origin git地址;例:https://github.com.git
- 创建一个分支
git branch -M main
- 将文件上传到分支下
git push -u origin main
标签:Aa,git,仓库,托管,Unity,Github,meta,ssets,gitignore From: https://blog.csdn.net/YTL2859447874/article/details/137035160