Since unreal engines assets are binary encoded classical text based git diff/merge tools will give up on merge conflicts of unreal assets.
But fear not!
You can setup your git environment to actually be able to diff/merge these .uasset
files by using already built-in functionallity of the unreal editor!
First of all do we have to create a small PowerShell-Script that copies the diff files into temporary files and to convert relative paths to absolute ones. This is necessery since some clients (like GitKraken) mess a bit with the files and Unreal Engine doesn’t seem to be able to use those files properly.
$UE_PATH = "G:/Projects/Satisfactory/SatisfactoryUnrealEngine/Engine/Binaries/Win64/UE4Editor.exe"
$PROJECT_PATH = "G:/Projects/Satisfactory/SatisfactoryModLoader/FactoryGame.uproject"
for ($i = 0; $i -lt $args.length; $i++) {
$args[$i] = Resolve-Path $args[$i]
$TempFile = New-TemporaryFile
Copy-Item $args[$i] -Destination $TempFile
$args[$i] = $TempFile
}
& $UE_PATH $PROJECT_PATH -diff $args
Replace the UE_PATH
and PROJECT_PATH
variables with the paths to your installations you want to use.
Save the file at a reasonable place for your git-config, I decided to place it right next to it C:\Users\MyUsername\Git_UE_Diff.ps1
.
Now that we have created our trampoline, we have to tell git about or new diff tool.
We do this by editing our .gitconfig
file.
This file is usually placed in your user directory C:\Users\MyUsername\.gitconfig
.
Warning
|
If the file is no visible, try to enable "show hidden files" in the view settings of your windows explorer |
In this file we now add a new diff and merge tool.
Each tool just simply calls our power shell script and passes the files to diff to the unreal editor in addition to the -diff
switch.
Also make sure to tell the diff/merge tool that it actually supports binary files.
[diff "CSS_UE_Diff"]
tool = UE_Diff_Tool
binary = true
[difftool "UE_Diff_Tool"]
cmd = "powershell C:/Users/MyUsername/Git_UE_Diff.ps1 \"$REMOTE\" \"$LOCAL\""
[merge "UE_Merge"]
tool = UE_Merge_Tool
binary = true
[mergetool "UE_Merge_Tool"]
cmd = "powershell C:/Users/MyUsername/Git_UE_Diff.ps1 \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\""
Make sure again to replace the paths to your powershell script accordingly.
Now you can use the Unreal Editor as external git diff/merge tool.
In that powershell script there's a path to a specific .uproject file. Does that mean this process will only work for git w/ that one project?