Can I integrate MLAPP files from App Designer with Git source control?

118 views (last 30 days)
Git cannot seem to track the plain text changes made to MLAPP source files from App Designer. Is there any workaround for the issue?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Jan 2021
Edited: MathWorks Support Team on 25 Jan 2021
From MATLAB R2020b, you can use MATLAB comparison tool to diff and merge two mlapp files as documented in Compare and Merge Apps with some limitation. See "Tips for Successful Merge" Section in Compare and Merge Apps
Also, you can also setup git inside MATLAB to perform different git actions as documented in Source control integration.  This generic MATLAB git support works mostly for mlapp file as well.
For example, when user has conflict on MLAPP file, use can resolve git conflicts by using Source Control > View Conflicts, then user can merge code differences by using MATLAB merge tool for MLAPP file. See "Resolve source Control Conflict" Documentation.
You can also learn to use this merge tool for mlapp files by watching this youtube video : How to Merge App Designer Apps with the MATLAB Comparison tool
If you use MATLAB R2020a and earlier versions, please refer the following information.
This is a known limitation of MLAPP files with version control. An enhancement request has been submitted for supporting version control of MLAPP files with Git. Our development team may consider this feature for a future release.
Possible workaround:
The current recommended workflow for version controlling MLAPP files with Git is to export the MLAPP file to a MATLAB code file (.m) and check-in this exported MATLAB code file with the MLAPP file. MATLAB R2018b added the ability to export an MLAPP-file directly to a M-file using the "Save -> Export to .m file" option on the App Designer's "Designer" toolstrip tab.
One potential workflow is to:
1. Save the app
2. Export the app to an .m file
3. Check in both the .mlapp and .m file to Git
4. Repeat for the next revision
While this does not offer merging of the app's code, it does offer change-tracking of the M-file that could be diffed as almost every aspect of the app appears in the generated code. So you could see if another developer added or removed components from the app by looking at the code added/removed. Also, when you export to an M-file, it will automatically append "_exported" to the file name, so you will not need to worry about it shadowing your MLAPP file.
An MLAPP file is a binary file similar to an MLX file and so it should be registered with Git as a binary format to prevent it from being corrupted. See the "Register Binary Files with Git" section in our documentation for more information:
Andy on 13 Aug 2022
Thanks. This answer may be helpful as we are using R2020b, and We have an app designer project with 2 or more developers (using Gitlab). But, we have an even more basic issue. The very act of clicking the Run icon in App Designer changes touches the .mlapp file, even though no changes have been made. As a minimum this is intimidating to people new to both git and Matlab. Is there a way to suppress this, or is the app/model being set up wrong?

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!