MATLAB Answers

How do I use live script (*.mlx) files in source control?

157 views (last 30 days)
I would like to use the live script files with source control, what is the workflow for that?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 9 Jul 2021
Edited: MathWorks Support Team on 9 Jul 2021
How to source control your files within MATLAB:
Since R2014b, you can integrate MATLAB with the Git source control system through the Current Folder browser (see the workflow shown in this video ).
To avoid corruption when doing so, you must register your MATLAB and Simulink file extensions such as .mlx, .mat, .fig, .mlapp, .mdl, .slx, .mdlp, .slxp, .sldd, and .p as binary formats. See more details here:
How to diff/merge your files:
Support for comparing live code (.mlx) files has been shipping with MATLAB since R2018a. A two-way merge tool was also added in R2018b. External version control tools can be configured to use MATLAB Comparison tool using the setup instructions outlined here:
Future improvements:
We're committed to making the Live Editor features work more seamlessly with source control – and we're also committed to providing an enhanced experience with plain text MATLAB files. We're working hard on both of these fronts, so stay tuned for future updates!
  7 Comments
Steven Lord
Steven Lord on 28 Sep 2021 at 15:26
@Olaf Bousche Rather than clearing all the output before checking the file in, have you tried configuring your SCM to use the tools we provide for comparing and merging live scripts (under "How to diff/merge your files" in the MathWorks Support Team's answer)? If so and if you found that solution unsatisfactory could you say a little more about why?

Sign in to comment.

More Answers (5)

Teemu Sillanpää
Teemu Sillanpää on 22 Mar 2018
So with the change from readable content (text) to binary, live scripts / to achieve .m files with documentation built in feature is totally useless in normal working environment (>1 user).

Markus Leuthold
Markus Leuthold on 1 Apr 2019
This is going into a completely wrong direction. Source code files must be text files. The toolchain does not only consist of Matlab, but many other such aus Github etc... which become unusable with these mlx files.
Unfortunately, there are already new features which are only available in the Live editor, but not in the classic editor or command window, such as tab completion via functionSignatures.json
  2 Comments
Michael Abboud
Michael Abboud on 29 Jun 2021
Hi Markus, I'm a developer on the MATLAB Editor team and I'm glad to share that this Auto Completion functionality from the Live Editor is now available in plain text (.m) MATLAB files in the R2021b pre-release of the MATLAB Editor!
Many of the other coding tools from the Live Editor (Block selection, Refactoring, etc.) are also now available in plain text (.m) MATLAB files – along with a refreshed look and feel – starting with the R2021b pre-release which launched last week.
We think this is a big step forward, and we're excited for you to give it a try! If you're able to install a new version of MATLAB, I'd encourage you to try out the R2021b pre-release and send us feedback:

Sign in to comment.


Richard Crozier
Richard Crozier on 21 Mar 2018
Edited: Richard Crozier on 21 Mar 2018
No you cannot use live scripts with any of the major version control systems such as svn, git or mercurial. They are a binary format and not compatible with these text difference based systems. Versioning the files will be possible in a very basic sense but none of the standard diffing and merging commands will work effectively, and none of the standard GUI tools for comparing versions will work as the files will simply appear as binary blobs.
You may be able to set up your source control system on one or two machines to work as specified in the Matlab docs, but no remote services such as Github or Bitbucket will support this.

Teemu Sillanpää
Teemu Sillanpää on 10 Jan 2018
Has this "readable content being source controlled as binary" been fixed already?
The whole idea of readable code is the ability to commit/diff changes in readable form in source controlled environment. Now zipping the .XML to a .xml without the source control understanding the nature of the content is purely wrong approach. Live scripts can be written/converted also in .m but this is not intuitive process in the GUI environment - ending up having two source controlled files (risk of being unsync) between .m and .mlx. Third option would be that Mathworks provides GIT tools which understand the .mlx as readable content. Or the .mlx files being converted to ASCII (.m ish) before source controlled.
Any of these properties implemented yet in the R2017b or coming R2018a?
  2 Comments
Steven Lord
Steven Lord on 10 Jan 2018
As of release R2016b you can customize your source control system to use the diff and merge tools included in MATLAB for binary .mlx files. See this page in the documentation for instructions on how to configure your system.

Sign in to comment.


Jan Kappen
Jan Kappen on 22 Jun 2021
Edited: Jan Kappen on 22 Jun 2021
Any updates on that? Workarounds? Plugins for Github or GitLab? Mathworks is effectively destroying any kind of collaboration, --automatic testing-- (wrong, see below) and code reviewing.
I'd stick to .m files if the editor wasn't that bad :(
Even juypter notebook files are in text format... The Notebook file format — nbformat 5.1 documentation
  9 Comments
Jan Kappen
Jan Kappen on 30 Jun 2021
I've receied the prerelease notification yesterday and was more than happy to read that the live editor features were ported back to .m files, this is awesome, thank you!
Thank you also for your last paragraph, it's good for us to know that work is being done and that a potential gap in means of source control is identified.
So thanks!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by