MATLAB: Does a Git pull (check-out) of .prj Simulink Project from the Git repository gives me an empty project

failgitprojectpullsimulink

When I add a .prj Simulink Project to a Git repository manually (outside MATLAB) and another user tries to pull the Simulink project, the project is empty and the contents are incorrect.  Why is it happening?

Best Answer

This is happening because .SimulinkProject folder was not added to the Git repository. The .prj file is just a “signpost” file that makes it easy to find and open a project. The project information is stored in .xml files in that (hidden) .SimulnkProject folder at the root of your project. Adding the .SimulinkProject folder in the Git repository will resolve the issue. 
 
If, within the project in Simulink, you run “Project Checks”, then one of these will fail because some of the files required by the project are not under source control. Running this check will also give suggestions to automatically fix the issue, i.e. it will push the missing .SimulinkProject in the Git repository.  Please refer to the following link for the details on running the Project Checks - 
https://www.mathworks.com/help/simulink/ug/run-project-checks.html
 
Also, if the initial Git Push (check-in) was done inside MATLAB using the built-in tools instead of doing it manually externally, then this problem wouldn’t have arisen. 
 
Related Question