Make Changes and Merge Git Local Branch
You are collaborating on models 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 occur in two model files.
1. Open the example to download the supporting files.
2. Switch from the main
branch to the taskBranch
branch. In the Current Folder browser, right-click and select Source Control > Branches. In the Branch Browser, select taskBranch
, and then click Switch.
Alternatively, in the Command Window, enter these commands.
repo = gitrepo;
switchBranch(repo,"taskBranch");
3. Make these changes to the sldemo_mdlref_counter
and sldemo_mdlref_basic
models and save the models.
In the
sldemo_mdlref_basic
model, in the Constant blockC5
, set the Constant value to110
.In the
sldemo_mdlref_counter
model, change the Scope block name fromScopeA
toScope
and in the Switch blockSwitch
, set the Threshold to0.25
Alternatively, in the Command Window, enter these commands.
topMdl = "sldemo_mdlref_basic"; refMdl = "sldemo_mdlref_counter"; load_system(refMdl); load_system(topMdl); modelNames=[refMdl,topMdl]; refBlockPath = append(refMdl,"/Switch"); set_param(refBlockPath,"Threshold","0.25"); refScopePath = append(refMdl,"/ScopeA"); set_param(refScopePath,"Name","Scope"); cstBlockPath = append(topMdl,"/C5"); set_param(cstBlockPath,"Value","110"); save_system(refMdl) save_system(topMdl) close_system(modelNames,0)
4. Commit your changes. In the Current Folder browser, right-click and select Source Control > View and Commit Changes.... Enter a commit message and click Commit.
Alternatively, in the Command Window, enter these commands.
commit(repo,Message = "Set Fixed step size to 0.003 and set InputSignalHandling and OutputSignalHandling to Auto/Zero-order Hold.");
5. Merge the branch taskBranch
into the main
branch. In the Current Folder browser, right-click and select Source Control > Branches. In the Branch Browser, select main
and click Merge.
Alternatively, in the Command Window, enter these commands.
try merge(repo,mainBranch) catch % The merge function throws an expected error because this branch merge % results in a conflict. % Unable to merge main into taskBranch. % Caused by: % Conflicted files: % sldemo_mdlref_basic.slx % sldemo_mdlref_counter.slx end
The branch merge results in conflicts in both model files. See the next steps to resolve the conflicts.