Work with Files Under SVN in MATLAB - MATLAB & Simulink (original) (raw)

Main Content

You can use Subversion® (SVN) source control in MATLAB® to manage your files and collaborate with others. Using SVN, you can track changes to your files and recall specific versions later.

Basic SVN workflow

After you check out an existing repository, you can add files to SVN source control and commit changes from the Files, Project, and Source Control panels. If the Source Control icon is not in the sidebar, click the Open more panels button Open more panels icon and select the Source Control panel.

Download an example under SVN source control using the Copy Command button.

Check Out Files from SVN Repository

You can check out files from a remote SVN repository using the https:// or the file:// protocols.

1. On the Home tab, in the File section, select New > SVN Checkout. Alternatively, in the Files or Project panel, right-click the white space and select Source Control > Check Out SVN Repository.

2. In the Check Out SVN Repository dialog box, specify the URL.

3. Specify the folder location of your working copy. The folder must be empty.

Use local folders. Using a network folder with SVN slows source control operations.

4. Click Check Out. If prompted, enter your login information for the remote repository. MATLAB, by default, remembers your usernames and passwords when you interact with SVN repositories. For information on how to disable credential management, see Configure SVN Settings.

To delete saved login information for an SVN repository, in the Files or Project panel, right-click the white space and select Source Control > Clear Credentials. Alternatively, in the Source Control panel, click the More source control options button More source control options icon and select Clear Credentials.

Get SVN File Locks

When you set up source control, you can configure SVN to make files with certain extensions read-only. Users must place a lock on read-only files before editing them. When a file has a lock, other users know the file is being edited and you can avoid merge issues. For more information, see Enforce Locking Files Before Editing.

SVN Locks dialog box with the list of locked files and their owners

Mark Files for Addition to SVN Source Control

When you create a new file in a folder under source control, the Not Under Source Control symbol Not Under Source Control icon appears in the status column of the Files panel.

To add files to source control, select and right-click the files you want to add. Then, select Source Control > Add to Source Control. The source control status changes in the source control column to Added Added icon.

If you use MATLAB projects to manage the files in the folder, MATLAB automatically adds all files with the status In project to source control.

Tip: As a design grows, managing referenced files and dependencies becomes more complicated. MATLAB Projects help you organize large hierarchies by finding required files, managing the path, creating shortcuts, and sharing files and settings. For more information, see Projects.

For large working folders, use the Source Control panel to view only the list of untracked files.

Update SVN File Status and Revision

To refresh the source control status of files and the icons in the source control column, right-click one or more files in the Files or Project panel and select Source Control > Refresh.

To refresh the status of all files in a folder, right-click the white space in the Files or Project panel and select Source Control > Refresh. Alternatively, in the Source Control panel, click the More source control options button More source control options icon and select Refresh.

Refreshing the SVN source control status does not contact the repository to get the latest file revisions. To get the latest file revisions, you must update your working folder using one of these options:

The illustration shows the Files and Source Control panel staked together. The SVN repository in the Source Control panel shows the list of modified files with a context menu listing all the options.

If you and another user change the same file in different SVN working folders, updating the working folder before you commit your changes might result in conflicts. For help resolving conflicts, see Resolve SVN Source Control Conflicts.

Review Changes in SVN Source Control

The source control status of every file that contains changes displays the Modified symbol Modified icon. To review changes before you commit them to SVN, in the Files or Project panel, right-click a modified file and select Source Control > View Changes.

To view only the list of modified files in large working folders, use the Source Control panel instead. To view local changes in these files, right-click a file and select View Changes.

You can also compare different revisions. In the Source Control panel, right-click a file and select Show Revisions. In the Log for file dialog box, select two revisions and click Compare Selected.

The Comparison Tool opens a side-by-side comparison. For more information, see Compare Text Files and Model Comparison (Simulink).

Commit or Revert Changes to Modified Files

Before you commit modified files, review your changes and mark any new files for addition into source control.

To commit the Added Added icon and the Modified Modified icon files, In the Source Control panel, click Commit. Alternatively, in the Files or Project panel, right-click and select Source Control > Commit.

Tip: You can configure MATLAB® to prompt you about unsaved changes before performing source control actions such as commit and update. For more information, see Configure Source Control Settings.

You can also discard changes you made instead of committing them to source control.

The source control status changes from Added Added icon and Modified Modified icon to Unmodified Unmodified icon.

Discard Changes in Modified Files

Discarding changes releases any locks and reverts the revision to the last update.

To revert a file to a specific revision, in the Source Control panel, right-click a file and select Show Revisions. In the Log for file dialog box, select the revision you want to revert to and click Revert.

See Also

Topics