Unity Version Control (Git)
Git Setup
-
Create a GitHub Repository
- Do not initialize with README or
.gitignore
(you’ll add Unity’s.gitignore
manually).
- Do not initialize with README or
-
Open Git Bash in Your Unity Project Folder & Initialize Git
git init git config --global user.name "xxxx" git config --global user.email "xxxxxx" git remote add origin <your-github-repo-link>
-
Add a Unity-Specific
.gitignore
File (Highly Recommended)Download and use the official Unity
.gitignore
:curl -o .gitignore https://raw.githubusercontent.com/github/gitignore/main/Unity.gitignore
-
Add README
echo "# Project Title" > README.md
-
Enable Git LFS (For Large Assets)
git lfs install git lfs track "*.psd" "*.png" "*.fbx" "*.mp4" "*.wav" "*.blend" git add .gitattributes
-
Add and Commit Files
git add . git commit -m "Initial commit" git branch -M main git push -u origin main
Check your GitHub to make sure the setup is successful
Basic Git Command
- Create New Branch
# Make sure you're in the root folder of your Unity project
# You're on main
git add .
git checkout -b new-experience
# commit and push as usual
git commit -m "Initial changes for new experience"
git push -u origin new-experience
Now you’re working on a completely separate version of the project.
- Merge Branch
Merge your branch into main
:
# Make sure you're on the main branch
git checkout main
# Merge your feature branch into main
git merge new-experience
# Push the changes to GitHub
git push
- Git Clone
Open Git Bash and run:
git clone https://github.com/your-username/your-repo.git .
Important:
- Use forward slashes (/) instead of backslashes () for Git Bash
- The Git repo is initialized inside your Unity project folder, not in a subfolder
- Double check which branch is currently active
This guide includes Git setup in Unity projects and basic Git commands.