Skip to content

Instantly share code, notes, and snippets.

@lokize
Created July 20, 2022 00:32
Show Gist options
  • Save lokize/6d5ef439d4928dab6be9b656a0662eba to your computer and use it in GitHub Desktop.
Save lokize/6d5ef439d4928dab6be9b656a0662eba to your computer and use it in GitHub Desktop.
unity git

Unity and Git integration

First, you have to make some configurations in the Unity project.

  1. Switch to Visible Meta Files in Edit → Project Settings → Editor → Version Control Mode
  2. Switch to Force Text in Edit → Project Settings → Editor → Asset Serialization Mode
  3. Click on Save Scene and Project from File menu.
  4. Quit Unity and then you can delete the Library and Temp directory in the project directory. You can delete everything, however keep the Assets and ProjectSettings directory.

Now you have to do the following:

  • Enter into the project directory: cd to/your/unity/project/folder and run:
echo "# project name" >> README.md
git init
echo .vs > .gitignore
echo Library >> .gitignore
echo Temp >> .gitignore
echo *.apk >> .gitignore
echo *.csproj >> .gitignore
echo *.sln >> .gitignore
echo /build >> .gitignore
echo /.vscode >> .gitignore

Bellow change projectName to your project name.

 echo /projectName_Data >> .gitignore

And run:

git add *
git commit -m "First commit"
  • Get the remote url from your repository. Example: git remote add origin git@github.com:username/project.git #(verify in your repository provider)
  • Run: git push -u origin --all for the first push.

For the "clone project" command

clone <put the url here>

For the "send code to server" commands

git add *  --adicionar novos arquivos
git commit -am "mensagem" -- faz o commit dos arquivos
git push

For the "get code from server" command

git pull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment