Use Source Control with MATLAB Projects - MATLAB & Simulink (original) (raw)

When you track your work using a project-based repository, you can perform source control operations directly from MATLAB®, similarly to how you perform source control from any repository. A project-based repository is a repository that also contains a MATLAB project to manage the path and settings. You can use Git™ or Subversion® (SVN) to track project files with source control.

To interact with source control, use the Project and the Source Control panels. You can access source control options from the Project toolstrip, the context menu in the Project panel, the context menu in the Source Control panel, and the More source control options button in the Source Control panel. If the Source Control and the Project icons are not in the sidebar, click the Open more panels button three-dot icon and add them.

To start using source control to track project files, use any of these workflows:

Perform Source Control Operations

In a project under source control, you can perform source control operations in MATLAB, similar to any other folder under source control. You can access source control options in:

Warning

For folders that contain projects, it is a best practice to open the project and use the Project panel instead of the Files panel. The Files panel is not aware of project features such as autorenaming or of information stored in project definition files.

For projects under Git source control, see Git in MATLAB.

For projects under SVN source control, see SVN in MATLAB.

Review Modified Project Files

You can identify modified or conflicted folder contents using the source control summary status in the Project panel. When you point to the file source control status, a tooltip displays if the file is modified, conflicted, added, deleted, or not under source control.

To only see the list of modified project files, use the Modified Files list in the Source Control panel.

Before you commit modified files to source control, you can run project checks. Project checks help you identify and fix issues, such as files that are under source control but not in the project, or derived files checked into source control. For more information, see Run Project Checks and Work with Derived Files in Projects Under Source Control.

To commit modified files to source control, see Review and Commit Modified Files to Git or Commit or Revert Changes to Modified Files under SVN Source Control.

Review Changes in Project Metadata

You can review changes in project metadata stored in the project definition files similarly to the way you review changes in other project files. You can review changes to shortcuts, labels, and project descriptions. The project stores this information in XML files in the resources folder. For more information about project definition files, see Project Definition Files.

You can identify modified or conflicted project definition files in theresources folder using the source control summary status in the Project panel. For large projects, to see only the list of modified project files, use the Modified Files list in the Source Control panel.

To review changes in a single project definition file, in the Project panel, right-click the file and select > . Alternatively, in the Source Control panel, in theModified Files list, right-click the file and selectView Changes.

The Comparison Tool opens a text comparison report.

Tip

Starting in R2025a, when you compare folders, MATLAB detects whether they are project root folders. The Comparison Tool opens a project definition files comparison report. For more information, see Compare MATLAB Projects.

Work with Derived Files in Projects Under Source Control

It is a best practice to omit derived and temporary files from your project or exclude them from source control. To check if derived or temporary files are part of your project, in the Project panel, in the Project toolstrip, clickProject Issues. In the Project Issues panel, in theChecks tab, click Run Checks. If you add the slprj folder to a project, the project checks advise you to remove this from the project and offer to make the fix. The derived files check is only enabled if the project is under source control.

It is a best practice to exclude derived files such as .mex*, the contents of the slprj folder, the sccprj folder, or other code generation folders from source control, because they can cause problems. For example:

See Also

Topics