Main Content

Configure Git Environment to Merge Requirement and Link Set 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:

    comparisons.ExternalSCMLink.setupGitConfig()
  2. Create a project and add the project to Git. For more information, see Use Source Control with MATLAB Projects.

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 creates a local Git repository in your working folder.

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

1. Open the Branch Manager and switch from the master branch to the taskBranch branch. In the Files panel, right-click and select Source Control > Branch Manager.

2. Commit your changes. In the Source Control panel, click Commit. Enter a commit message and click Commit.

3. To merge changes from origin/master branch to taskBranch, set origin/master branch as the current branch and select taskBranch branch in Branch Browser. Then, 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.

  • 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.

See Also

Topics