Git Setup

  1. Create a GitHub Repository

    • Do not initialize with README or .gitignore (you’ll add Unity’s .gitignore manually).
  2. 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>
    
  3. 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
    
  4. Add README

     echo "# Project Title" > README.md
    
  5. Enable Git LFS (For Large Assets)

     git lfs install
     git lfs track "*.psd" "*.png" "*.fbx" "*.mp4" "*.wav" "*.blend"
     git add .gitattributes
    
  6. 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

  1. 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.

  1. 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
  1. 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.