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)
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.
List layout 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
Select the Modified (
files) tab to check changes. On the
Project tab, click
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 conflict (e.g.,
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 Merge. The selected difference is copied from the left file to the right file.
Merged differences display gray row highlighting and a green merge arrow.
The merged file name at the top of the report displays the dirty
show you that the file contains unsaved changes.
Click Save Merged File to save the file on the right. Check the file path of the right file in the comparison report. (To save to a different file, select Save Merged File > Save Merged File As). To resolve conflicts, save the merged file over the conflicted file.
If you want to inspect the files in the editor, click the line number links in the report.
If you make any further changes in the editor, the comparison report does not update to reflect changes and report links can become incorrect.
After merging to resolve conflicts, mark the conflict resolved and commit the changes, as described in Resolve Conflicts.
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.
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.
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.