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.
- 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).
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.
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.
-
Install Unity.
-
Install Git. During instalation, be sure to select Git LFS when asked:
-
Create a GitHub account.
-
Launch Git Bash and run the following commands:
git config --global user.name "<< Your GitHub username >>"
git config --global user.email "<< Your GitHub email >>"
-
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:
-
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:
The following steps are only necessary if you don't already have a Git GUI configured.
-
Launch Sourcetree and login to your remote (your GitHub account).
-
Go to
Tools > Options > Diff
. -
Select "P4Merge" in the External Diff Tool dropdown.
-
Select "Custom" in the Merge Tool dropdown.
Type the path to UnityYAMLMerge in the Merge Command text field (it's usually located atC:\Program Files\Unity\Hub\Editor\ <<Unity Version>> \Editor\Data\Tools\UnityYAMLMerge.exe
).
Typemerge -p $BASE $REMOTE $LOCAL $MERGED
in the Arguments field for the Merge Tool.
-
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
- (Ignore this step if you're using P4Merge as a mergetool)
Open themergespecfile.txt
file (located in the same folder as theUnityYAMLMerge.exe
, usually atC:\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"
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).
-
Use this repository as a template (click on the green "Use this template" button on this repository's page).
This will copy the folder structure and files of this repository to a new repository of your own. -
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.
-
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.
-
Open the chosen destination folder (the cloned repository folder on your computer) and delete
README.md
file andTutorial
folder. -
Rename
Unity Project Folder
to the project name you want. -
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.