Integrating Simulink and Stateflow with git + GitExtensions using SimDiff
Set ToolSelector as the diff and merge tool in Git Extensions, and SimDiff opens for Simulink models.
Git is a distributed version control system. The primary interface is the command line. Git Extensions is a graphical client on top of that command line. These steps configure SimDiff for Git Extensions.
This client uses ToolSelector. ToolSelector is an ENSOFT utility that picks a configured tool from the input arguments, for example the file type. The ToolSelector User Guide.pdf is in the ToolSelector directory. By default that directory is C:\Program Files\EnSoft\SimDiff\utils\toolselector. If you use a SimDiff version older than 2020a.2, the directory is C:\Program Files\EnSoft\SimDiff\utils\toolselector-20120215-1803.
Configuration
- Download
gitExtensions-simdiff.zip. - Copy the extracted files to your ToolSelector directory (by default,
C:\Program Files\EnSoft\SimDiff\utils\toolselector). - Configure Git Extensions’ external diff and merge tools:
- Open Git Extensions.
- Click Tools, then Settings.
- Enter the following in the Git Config section under the Git Extensions configuration, as in the picture below.
Mergetool: simdiff
Path to mergetool: C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe
Mergetool command:
"C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe" -profile=3way-merge $PWD $MERGED $REMOTE $BASE $LOCALDifftool: simdiff
Path to difftool: C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe
Difftool command:
"C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe" -profile=2way $PWD $LOCAL $REMOTE
Notes
- If SimDiff and ToolSelector are not in their default locations, change the paths in step 3.
- If ToolSelector is not in its default location inside the SimDiff directory, update
simdiff-cd.batwith the correct absolute or relative path tosimdiff4.exe. - Use a 3-way diff as part of the merge. A 3-way diff shows what differs between two versions and which model each change came from. 3-way diff is included in every edition of SimDiff.
Usage
To see the differences between two versions of a model, click Open with difftool, then the option you want (for example First to Second). Git Extensions opens SimDiff. The picture shows this for an unstaged file compared with the copy in the repository.

SimDiff also launches when Git Extensions finds a merge conflict. The steps below merge a branch into the branch that is checked out. Right-click the branch to merge and follow the pictures.




In this dialog, click Start mergetool to open SimDiff and merge the changes.


Use SimDiff to merge the changes. When you are done, save the model from the Simulink window and close SimDiff. The next dialog appears.


Commit the merged model.
Using another client? See Version Control Setup.
