If you and another user change the same file in different sandboxes or on different branches, a conflict message appears when you try to commit your modified files. Extract conflict markers if necessary, compare the differences causing the conflict, and resolve the conflict.
Look for conflicted files in the Modified (number of files) tab.
Identify conflicted folder contents using source control summary status. Folders display rolled-up source control status. This makes it easier to locate changes in files, particularly conflicted files. You can hover over the source control status for a folder to view a tooltip displaying how many files inside are modified, conflicted, added or deleted.
Listlayout to view files without needing to expand folders.
Check the source control status column (Git or SVN) for files with a red warning symbol, which indicates a conflict.
Right-click the conflicted file and select View Conflicts to compare versions.
Examine the conflict. The project opens a comparison report showing the differences between the conflicted files.
For SVN, the comparison shows the differences between the file and the version of the file in conflict.
For Git™, the comparison shows the differences between the file on your branch and the branch you want to merge into.
For model files, see Merge Simulink Models from the Comparison Report.
Use the comparison report to determine how to resolve the conflict.
To resolve conflicts you can:
Use the report to merge changes between revisions.
Decide to overwrite one set of changes with the other.
Make changes manually from the project by editing files, changing labels, or editing the project description.
When you have resolved the changes and want to commit the version in your sandbox, in a project, right-click the file and select Source Control > Mark Conflict Resolved. You can use the merge tool to mark the conflict resolved, or you can choose to manually mark the conflict resolved in the project.
For Git, the Branch status in the Git pane changes from
Select the Modified (number of files) tab to check changes. On the Project tab, click Commit.
Merge Text Files
When comparing text files, you can merge changes from one file to the other. Merging changes is useful when resolving conflicts between different versions of files.
Conflict markers appear in a text comparison report like this:
You can merge only from left to right. When comparing to another version in
source control, the right file is the version in your sandbox. The left file is
either a temporary copy of the previous version or another version causing a
Observe the file paths of the left and right file at the top of the comparison
report. Merge differences from the left (temporary copy) file to the right file
to resolve conflicts.
In the Comparison Tool report, select a difference in the report and click Replace Content. The selected difference is copied from the left file to the right file.
To undo the content replacement, click Undo.
Alternatively, use the inline Replace Content and Undo icons.
The merged file name at the top of the report displays the dirty flag (
) to show you that the file contains unsaved changes.
Click Accept & Close to save the merge changes and mark the conflicts resolved.
In the Comparison Tool report, you can merge changes between revisions. For details, see Merge Simulink Models from the Comparison Report.
After merging to resolve conflicts, the merge tool can mark the conflict resolved for you, or you can choose to manually mark the conflict resolved. Then commit the changes, as described in Resolve Conflicts.
Extract Conflict Markers
What Are Conflict Markers?
Source control tools can insert conflict markers in files that you have not registered as binary (e.g., text files). You can use project tools to extract the conflict markers and compare the files causing the conflict. This process helps you to decide how to resolve the conflict.
Register model files with source control tools to prevent them from inserting conflict markers and corrupting models. See Register Model Files with Source Control Tools. If your model already contains conflict markers, the project tools can help you to resolve the conflict, but only if you open the model from the project. Opening a model that contains conflict markers from the Current Folder or from a file explorer can fail because Simulink® does not recognize conflict markers.
Conflict markers have the following form:
<<<<<<<["mine" file descriptor] ["mine" file content] ======= ["theirs" file content] >>>>>>>["theirs" file descriptor]
If you try to open a file marked conflicted that contains conflict markers, the Conflict Markers Found dialog box opens. Follow the prompts to fix the file by extracting the conflict markers. After you extract the conflict markers, resolve the conflicts as described in Resolve Conflicts.
To view the conflict markers, in the Conflict Markers Found dialog box, click Load File. Do not try to load model files, because Simulink does not recognize conflict markers. Instead, click Fix File to extract the conflict markers.
By default, the project checks only conflicted files for conflict markers. You can change this preference to check all files or no files. Click Preferences in the Project tab to change the setting.
Extract Conflict Markers
When you open a conflicted file or select View Conflicts, the project checks files for conflict markers and offers to extract the conflict markers. The project checks only conflicted files for conflict markers unless you change your preferences setting.
However, some files that are not marked conflicted can still contain conflict markers. This can happen if you or another user marked a conflict resolved without removing the conflict markers and then committed the file. If you see conflict markers in a file that is not marked conflicted, you can remove the conflict markers.
In a project, right-click the file and select Source Control > Extract Conflict Markers to File.
Leave the default option to copy the “mine” revision over the conflicted file. Leave the Compare check box selected. Click Extract.
Use the Comparison Tool report as usual to continue to resolve the conflict.