Skip to content

An Unity+Git project template. Also includes integration with GitHub, Sourcetree and P4Merge, but any other remotes/tools can be used instead. Use this repository as a template and follow the steps described below.

Notifications You must be signed in to change notification settings

ThiagoRangel7/unity-git-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity+Git+Remote Template

This repository is an Unity + Git project template. The complete setup also includes integration with GitHub, Sourcetree and P4Merge, but any other GUI, remote or merge tool can be used instead.

Just use this repository as a template and follow the steps described below.

Features

  • Ignores Windows generated files (cache and temporary files) accordingly to GitHub's official .gitignore Windows template (Link).
      .gitignore in root folder.
  • Ignores backup files accordingly to GitHub's official .gitignore backup files template (Link).
      .gitignore in root folder
  • Ignores Unity related files accordingly to GitHub's official .gitignore Unity template (Link).
      .gitignore in Unity's project folder.
  • Supports Git-LFS for common 3D models, images, audio, videos, archives and fonts file formats.
      .gitattributes in root folder.
  • Supports Unity SmartMerge (aka Unity YAML Merge) to smartly solve conflicts and merge Unity scenes and prefabs.
  • Supports external Git GUI (Sourcetree used).
  • Supports external Diff & Merge tools (P4Merge used).
  • Supports a remote repository (GitHub used).

Step-By-Step Guide

This step-by-step guide will teach you how to setup:

  • Git + Git-LFS (Version Control System)
  • GitHub (Remote Repository)
  • Sourcetree (Git GUI)
  • P4Merge (Diff & Merge tool)
  • Unity (Game Engine)
  • Unity SmartMerge (Unity tool to enable scene and prefab merging)

While Git, Unity and Unity SmartMerge are necessary, the other tools (GitHub, Sourcetree and P4Merge) can be replaced for other remotes, GUIs and mergetools of your own preference.

These steps need to be done only *once per machine*.


1 - Installation

The following steps are only necessary if you don't already have Unity, Git, GitHub, a Git GUI and a Diff & Merge tool installed/configured.

  1. Install Unity.

  2. Install Git. During instalation, be sure to select Git LFS when asked:
    Git LFS Setup

  3. Create a GitHub account.

  4. Launch Git Bash and run the following commands:

git config --global user.name "<< Your GitHub username >>"
git config --global user.email "<< Your GitHub email >>"
  1. Install the Git GUI (Sourcetree). You will have to create a BitBucket account.
    During installation, be sure to select/deselect accordingly to the image below:
    Sourcetree Setup

  2. Install the external Diff & Merge tool (P4Merge). This is a software specialized in showing differences between files and helping the user solve merge conflicts.
    During installation, be sure to deselect all other apps and install only the Diff and Merge tool P4Merge:
    P4Merge Setup  
     

2 - Sourcetree + P4Merge + Unity SmartMerge setup

The following steps are only necessary if you don't already have a Git GUI configured.

  1. Launch Sourcetree and login to your remote (your GitHub account).

  2. Go to Tools > Options > Diff.

  3. Select "P4Merge" in the External Diff Tool dropdown.

  4. Select "Custom" in the Merge Tool dropdown.
    Type the path to UnityYAMLMerge in the Merge Command text field (it's usually located at C:\Program Files\Unity\Hub\Editor\ <<Unity Version>> \Editor\Data\Tools\UnityYAMLMerge.exe).
    Type  merge -p $BASE $REMOTE $LOCAL $MERGED  in the Arguments field for the Merge Tool.
    Sourcetree Diff&Merge Setup

  5. Launch Git Bash and run the following command (it will keep Git from creating lots of backup ".orig" files that can quickly clutter up your repository folder when merge conflicts occur):

git config --global mergetool.keepBackup false
  1. (Ignore this step if you're using P4Merge as a mergetool)
    Open the mergespecfile.txt file (located in the same folder as the UnityYAMLMerge.exe, usually at C:\Program Files\Unity\Hub\Editor\ <<Unity Version>> \Editor\Data\Tools\mergespecfile.txt). This file describes which Diff & Merge tool will be used when Unity SmartMerge can't solve merge conflicts without human intervention and which Diff & Merge tool will be used for non-Unity files.
    There are some preconfigured Diff & Merge tools listed in the file. If the tool you want to use is already listed, you don't have to do anything (P4Merge, for example, is already listed). Otherwise, replace the following lines:
unity use "%programs%\YouFallbackMergeToolForScenesHere.exe" "%l" "%r" "%b" "%d"
prefab use "%programs%\YouFallbackMergeToolForPrefabsHere.exe" "%l" "%r" "%b" "%d"

with:

unity use "<< path to yourMergeTool.exe >>" "%l" "%r" "%b" "%d"
prefab use "<< path to yourMergeTool.exe >>" "%l" "%r" "%b" "%d"

 

3 - Unity project setup

After you finished the previous steps, you just have to use this repository as a template for each Unity project you want to start. It's already configured with everything you need (Git LFS, .gitignore files, .gitattributes file, Unity Editor setup and a folder for your project).

  1. Use this repository as a template (click on the green "Use this template" button on this repository's page).
    "Use this template" button
    This will copy the folder structure and files of this repository to a new repository of your own.

  2. Open your newly copied repository's page on GitHub and click on the green "Clone or download" button. Copy the link on the popup window.
    "Clone or download" button

  3. Open Sourcetree, click on the "Clone" button, paste the link, choose the destination folder and confirm. This will download the repository to your computer and automatically link it to your GitHub account.
    Sourcetree clone

  4. Open the chosen destination folder (the cloned repository folder on your computer) and delete README.md file and Tutorial folder.

  5. Rename  Unity Project Folder  to the project name you want.

  6. Open Unity Hub (aka Unity Launcher), go to Projects tab and click the "ADD" button. Select the Unity Project Folder you renamed on step 5.

Make a game.

About

An Unity+Git project template. Also includes integration with GitHub, Sourcetree and P4Merge, but any other remotes/tools can be used instead. Use this repository as a template and follow the steps described below.

Resources

Stars

Watchers

Forks

Packages

No packages published