在simuli金宝appnk上的家伙

金宝app基于Simulink和模型的设计

三通模型合并和git

In R2016a, a newThree-Way Model Mergefunctionality got introduced. You can find a clear description of this feature in the following documentation pages:

在这些文档页面中,工作流程始终开始right-click on the conflicted model file and select查看冲突

Conflicted file

In this blog post, I will try to provide a bit of additional information to complement the workflow described in the above links.

Creating a Conflict

I created a simple project under Git source control. I could have usedGitHub, but I decided to use a Git server we have at MathWorks. At the Git command-line, I cloned two identical repositories:

Git Clone

two Projects

在第一个存储库中,我对模型进行了一些修改。我进入Simulink项目的修改文件视图,提交修改文件并将更改推到远程存储库金宝app

commit and Push

我关闭第一个项目,导航到第二个存储库,在那里打开Simulink项目,并以不同的方式修改模型。金宝app

Resolving the Conflict

Before trying to commit and push changes as done in the first repository, it is always a good idea to click theFetchbutton to get the latest from the remote repository. Once this is done, you can see if the remote master branch has new submissions. If it does, you want to merge with it before pushing your changes.

Merge

Because of the conflict, you will receive this error:

Merge Error

If you go back to Simulink Project, the conflicting files will look like:

git冲突

Right click on the file and select查看冲突启动三方模型合并工具。然后,您将能够看到:

  • 原始模型
  • The latest model in repository 1
  • The latest model in repository 2
  • Simulink自动生成的目标模型,试图在合并前一个模型时进行最佳猜测。金宝app

Three-Way Model Merge

In the bottom left section of the Three -Way Model Merge, for each block and signal, you can select which version you want to be merged in the target model. For conflicts that cannot be automatically merged, you can manually fix them in the target model and individually mark them as resolved.

从存储库1,库自版本2and the target model can all be opened at the same time, this makes the manual resolution of conflicts quite easy.

Zoom on model merge

Once you are satisfied with the target model, click the接受和关闭button:

Accept and Close

然后,您将能够提交修改后的文件并将更改推向存储库。如果单击“管理分支”按钮,则应查看项目如何进行分支并将其合并。

branch evolution

One more tip...

In most cases, this kind of merging challenges happen within the context of a project under source control. However if you just want to launch the tool without any project or source control involved, you can use the following syntax:

slxmlcomp.slmerge(basefile,minefile,thinsfile,targetfile);

where the 4 inputs are four model files.

现在轮到你了

How do you manage branching? Give a try at the Three-Way Model Merge and let us know what you think by leaving acomment here

|

コメント

コメントを残すには、ここをクリックしてMATHWORKSアカウントアカウントサインインするか新闻MATHWORKSアカウントを作品成します。