Simple basic template to clone and used for MATLAB-Simulink projects. Essentially provides
- a
.gitignore
file, - m
.gitattributes
file for merging (binary) Simulink models - and some instructions to set up and use MATLAB Simulink for use with Git
According to MATLAB's documentation:
-
seup MATLAB (from MATLAB console)
comparisons.ExternalSCMLink.setup()
-
Add MATLAB diff to your
.gitconfig
. This can be done from within MATLAB withcomparisons.ExternalSCMLink.setupGitConfig()
Note for Windows users: In some cases MATLAB writes
$PWD/
before the path in sections[mergetool "mlMerge"]
and[difftool "mlDiff"]
. This may fail using the git command line, as mlDiff writes the model versions to yourTemp
folder and then use the wrong path ($PWD/C:/Users/.../Temp/*.slx
). Just delete the$PWD/
parts. Your.gitconfig
sections should look like[mergetool "mlMerge"] cmd = \"C:/Program Files/MATLAB/R2020b/bin/win64/mlMerge.exe\" $BASE $LOCAL $REMOTE $MERGED [difftool "mlDiff"] cmd = \"C:/Program Files/MATLAB/R2020b/bin/win64/mlDiff.exe\" $LOCAL $REMOTE
You need to replace your MATLAB path in the above example.
-
The
.gitattributes
file of this directory automatically dispatches merges on Simulink models to MATLAB. I.e., models will be truly merged instead of only applying the newer version.
Again, following MATLAB's documentation: diff (from command line) with
git difftool -t mlDiff <revisonID1> <revisionID2> myModel.slx
# e.g. diff with previous version
git difftool -t mlDiff HEAD HEAD~1 myModel.slx