Review and Commit Modified Files to Git - MATLAB & Simulink (original) (raw)

This example shows how to review and commit or stash modified files in a Git™ repository. You made changes to files in your local Git™ repository by adding copyrights at the end of every file. If you have not yet initialized a Git repository, see Create Local Git Repository in MATLAB.

Open the example to download the supporting files under Git source control.

Review Modified Files

The source control status of every file that contains changes displays the Modified symbol .

To review changes before you commit them to Git, in the Files or Project panel, right-click a modified file and select Source Control > View Changes.

In large repositories, to view only the list of modified files, use the Source Control panel instead. 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. The Source Control panel lists seven modified files in the example repository.

To view local changes in these files, right-click a file and select View Changes.

Source Control panel displaying 7 modified files int the repository with the context menu open

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 Modified Files

To commit modified files, In the Source Control panel, click Commit.

Alternatively, in the Files or Project panel, right-click in the blank space and select Source Control > Commit.

In the Commit Changes dialog box, enter the commit message and click Commit.

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

The source control status changes from Modified to Unmodified .

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

Discard Changes in Modified Files

Stash Changes in Modified Files

Store uncommitted changes for later use by creating a Git stash. You can use stashes to store modified files without committing them or to move changes easily to a new branch in the same repository.

To stash all local changes, in the Source Control panel, click the More source control options button and select Stash Changes. In the Stash Files dialog box, provide the stash name and click Stash.

Alternatively, in the Files or Project panel, right-click in the blank space and select Source Control > Stash Changes.

You can manage stashes and apply changes to the current branch.

Stashes dialog box displays the list of modified files, context menu, and Apply, Pop, and Delete buttons.

See Also

Tools

Topics