MATLAB: How to revert the Simulink Project to a specific revision when using Git

simulink

I want to revert the entire Simulink Project to a specific revision. I am using Git source control.
How can I do that?

Best Answer

It is not currently possible to do this with the Simulink Project UI.
As a workaround, do the following:
1) Open the git branch manager, find the ID of the commit that you want to revert to, and note that down.
2) Close the project.
3) In MATLAB Command Window, reset the HEAD to the second revision:
>> !git reset --hard [commitID]
At this point, the HEAD and the "master branch should be at the same location. Next, create and add a new script into the project. Open Simulink Project and click Commit.
At the end of this, you should be able to see in the Simulink Project > Branches window similar to the attached file: commit.PNG
In general, MATLAB path will prevent any source control tool from deleting folders that are on the path. MATLAB's git integration can work around this issue, but command line git might cause problems.
If reverting the project will not involve folder deletion, then the project can be kept open.