Simulink and Git - Compare branches

4 ビュー (過去 30 日間)
Guilherme Sinoara
Guilherme Sinoara 2015 年 9 月 23 日
回答済み: Swastik Sarkar 2025 年 5 月 29 日
Is there any way to compare Git branches on a Simulink project? In other words, show which files are different before merging.
  2 件のコメント
Bogdan Bodnarescu
Bogdan Bodnarescu 2022 年 6 月 13 日
I am interested about this too, also did you find a way to make git merge work properly for simulink models?
For me the results given by the merge makes no sense, I basically have to do all the merges manually otherwise the merged model will be a total disaster.
Mark
Mark 2024 年 2 月 26 日
I'm interrested in this as well.
Right now I have to do a checkout of the branch, copy the .slx to a new folder, checkout my stuff again, and use Simulink to compare.
Even then, a "git merge --no-commit " is recommended to make it easy to use a file-compare tool (like Araxis merge or Beyond compare) to grab what you want...then do your git add, git merge --continue.

サインインしてコメントする。

回答 (1 件)

Swastik Sarkar
Swastik Sarkar 2025 年 5 月 29 日
Hello,
To identify files with differing content between two branches, the following command may be used:
git diff branch1..branch2 --name-only
For binary files such as Simulink models, MAT files, and similar formats, standard diff tools do not provide meaningful output. In such cases, both versions of the file must be present on disk for comparison.
While on branch1, the version of model.slx from branch2 can be extracted using:
git show branch2:path/to/model.slx > model-branch2.slx
The differences can then be visualized in MATLAB using:
visdiff('model.slx', 'model-branch2.slx');
Hope this helps !

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by