How I Resolve Git Conflicts in Simulink Models (Without Losing My Mind)
In one of my previous tutorials, I explained how to set up version control for Simulink models using Git. But let’s be honest—once binary files like .slx
or .mlx
are involved, merging conflicts becomes a real headache.
I’ve dealt with this many times, especially during collaborative development where multiple team members push changes to the same Simulink model. Simulink does offer a graphical model comparison and merge tool, but I often find it clunky and unreliable for real conflict resolution.
So here’s how I personally handle Git conflicts in Simulink models step by step:
Handling Binary File Conflicts in Git for Simulink
When Git encounters a conflict in binary files, it can’t auto-merge them like it can with plain text. So you have to choose—whose version do you want to keep?
1. Identify the Conflicting File
In my case, the file Git flagged was:
Experimennt_RL/2024-07-28_PMSM_TD3/PMSM_TD3_Base/TrainTD3AgentForPMSMControlExample.mlx
2. Choose Which Version to Keep
You typically have three choices:
-
Keep your local version
-
Accept the remote version
-
Go back to a specific commit
3. Run Git Commands to Resolve the Conflict
To keep your local version:
git checkout --ours Experimennt_RL/2024-07-28_PMSM_TD3/PMSM_TD3_Base/TrainTD3AgentForPMSMControlExample.mlx
To keep the remote version:
git checkout --theirs Experimennt_RL/2024-07-28_PMSM_TD3/PMSM_TD3_Base/TrainTD3AgentForPMSMControlExample.mlx
To go back to a previous commit version:
First, find the commit hash:
git log Experimennt_RL/2024-07-28_PMSM_TD3/PMSM_TD3_Base/TrainTD3AgentForPMSMControlExample.mlx
Then check out the desired version:
git checkout [commit_hash] Experimennt_RL/2024-07-28_PMSM_TD3/PMSM_TD3_Base/TrainTD3AgentForPMSMControlExample.mlx
4. Mark the File as Resolved
Once you’ve decided which version to keep, run:
git add Experimennt_RL/2024-07-28_PMSM_TD3/PMSM_TD3_Base/TrainTD3AgentForPMSMControlExample.mlx
5. Complete the Merge
Now commit your changes:
git commit -m "Resolved binary file conflict in TrainTD3AgentForPMSMControlExample.mlx"
6. Push Your Final Changes
Finally, push your resolution to the remote branch:
git push origin master
In short, working with binary files in Git isn’t ideal, but once you understand the workflow, you can resolve conflicts without panicking. Hope this helps anyone stuck resolving .mlx
or .slx
merge issues—been there too many times myself.
👋 About Me
Hi, I’m Shuvangkar Das, a power systems researcher with a Ph.D. in Electrical Engineering from Clarkson University. I work at the intersection of power electronics, DER, IBR, and AI — building greener, smarter, and more stable grids. Currently, I’m a Research Engineer at EPRI (though everything I share here reflects my personal experience, not my employer’s views).
Over the years, I’ve worked on real-world projects involving large scale EMT simulation and firmware development for grid-forming and grid following inverter and reinforcement learning (RL). I also publish technical content and share hands-on insights with the goal of making complex ideas accessible to engineers and researchers.
📺 Subscribe to my YouTube channel, where I share tutorials, code walk-throughs, and research productivity tips.
📚References
[[Git Manage Binary Files Conflict]]
Leave a comment