Technology Sharing

Git-Unity project version management

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

This article records how to use gitunity The project is version managed and can be transferred to GitHub remotely.

Prepare

nameVersion
windows11
Unity2202.3.9.f1
gitN.A.
githubN.A.

GitHubCreate a new project and add an ssh key

  1. Create a new repository on GitHub
  2. Windows 11 Generate ssh-key (optional)
ssh-keygen -t rsa
cd ~/.ssh
dir
cat id_rsa.pub
  • 1
  • 2
  • 3
  • 4

insert image description here
3. Copy the contents of id_rsa.pub to the Deploy keys under the repository's Settings
insert image description here

Unityfolder

Configure git for the Unity project folder

git init
添加 .gitignore (此步为重点,可避免上传冗余文件:可直接从此处下载放在文件夹里即可 https://github.com/github/gitignore/blob/main/Unity.gitignore)
添加 .gitattributes (此步为重点,可直接从此处下载放在文件夹里即可 https://github.com/gitattributes/gitattributes/blob/master/Unity.gitattributes)
git add .
git commit -m "自定义备注"
git status 

git remote add origin <[email protected]:xxx/xxx.git>
git push -u origin master #上传至branch: master,可根据需要换至其他branch
git status
git log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

insert image description here

refer to:
https://unityatscale.com/unity-version-control-guide/how-to-setup-unity-project-on-github/