Main Content

Configure Git Environment to Merge Requirement and Linkset Files

If multiple users are working on the same requirement set and link set files in Git™, you can merge the changes into a single file by using the mlAutoMerge command.

You can follow the process described in Customize External Source Control to Use MATLAB for Diff and Merge with Requirements Toolbox™ to merge changes in different branches in Git.

To use mlAutoMerge with the Git tool:

  1. At the MATLAB® command prompt, enter this command:

  2. Create a project and add the project to Git. For more information, see Add Existing Project to Source Control.

Make Changes and Merge Branches in Git

This example shows how you can make changes in requirements set and merge branches that are under Git™ source control. You work on some changes in your local branch taskBranch. When you attempt to merge your branch into the main branch, merge conflicts can occur.

Open the example to download the supporting files. The supporting files contain a requirements file that you can change and merge the branches using the script create_branch.m. This script create a local Git repository in your working folder.

Follow these steps to manually switch from one branch to another and commit the changes:

1. In your local Git repository, switch from the main branch to your branch taskBranch. In the Current Folder browser, right-click and select Source Control>Branches. In the Branch Browser pane, select taskBranch and click Switch.


2. Commit your changes. In the Current Folder browser, right-click and select Source Control>View and Commit Changes....


4. Merge branch taskBranch into the main/origin branch. In the Current Folder browser, right-click and select Source Control>Branches. In the Branch Browser, select main and click Merge.


Note: If there are no conflicts in merging the branches, then a merge operation modifies the target file. If there are conflicts, you must view and resolve the conflicts manually. For more information, see Resolve Conflicts in Requirements Using Three-Way Merge.

Note: During automerge, a log file <requirement_set_name>_merge_<timestamp>.log may be generated in the Git repository folder once the merge operation is complete. The log file contains changes in the SID values of the requirements during merging of requirement set (slreqx) files.

Related Topics