Skip to content

Merge Conflicts

Jaden Balogh edited this page Jun 5, 2021 · 2 revisions

Dealing with Asset Merge Conflicts in Unity

Often, when making a Pull Request (PR) into the dev branch, you will find that your current changes conflict with new changes that have been made to the dev branch. Normally these can be resolved easily within VSCode using its built-in merge conflict interface - however, if the conflicts are in an asset file, such as a Scene or a Prefab, you may be unable to resolve the conflict yourself. For these cases, we can resolve the vast majority of conflicts using UnityYAMLMerge.

Setting up UnityYAMLMerge

Go to your local folder where you installed the Unity project and ensure you have hidden folders set to visible in your file explorer (on Windows, this is under View -> Hidden Items). Open up the .git folder and open the config file with your preferred text editor (you can even use VSCode).

Anywhere in that file after existing items (yours may vary depending on your Git setup), add the following lines:

[merge]
  tool = unityyamlmerge
[mergetool "unityyamlmerge"]
  trustExitCode = false
  cmd = 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.2.1f1\\Editor\\Data\\Tools\\UnityYAMLMerge.exe' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"

Your file paths may vary, and this will need to be done for each Unity project you are working on.

Running UnityYAMLMerge

Your project folder should now be configured to use UnityYAMLMerge. To use this, anytime you encounter a merge conflict involving an asset file such as Main.unity, you can simply run the following command in the command line:

git mergetool

Note that you will have to run this in the base folder of the project, so ensure that you are in the correct directory - on Windows you can use this command before running git mergetool:

cd C:\My\Path\To\Project\rpg

Feel free to ask in #rpg-discussion in the Discord server if you have any problems!

Credit

Thanks to this article for providing many of the details needed to setup this process.

About

> Home
> Our Team
> Milestone 1: αω plasmashark

Programming

Setup
> Merge Conflicts
> Using GitHub

Tools
> Behaviour Trees

Game Systems

Character
> Level Progression
> Alignment
> Inventory

Gameplay
> Gameplay Loop
> Combat
> Quests
> Items
> Dialogue

Content Design

Art
> Art Style
> Thematic Decisions
> UI

Music + Sound
> Inspiration Board

Story
> Prologue

Clone this wiki locally