Skip to main content
All CollectionsFAQs
What is Semantic Merge?
What is Semantic Merge?
Steve Ballantine avatar
Written by Steve Ballantine
Updated over a week ago

Semantic merge is Gearset's custom git merge driver.

It has been created in order to more intelligently merge changes in Salesforce Metadata files.

The standard git merge driver does an excellent job in most scenarios. However, there are many in which it can get things wrong. These fall into 2 main types:

Git merge thinks there are conflicts but Semantic merge knows they're not conflicts

This can happen in many scenarios, but a common example is when adding new fields to objects:

  1. In branch A, we add a field F1 to an object.

  2. In branch B, we add a different field F2 to the object and it ends up in the same place in the metadata XML file.

Git merge doesn't know whether to put F1 before F2 or vice versa, so will report a conflict. Semantic merge knows that the order doesn't matter here so will just add both fields to the object without a conflict.

Git merge thinks there are no conflicts but it introduces Salesforce validation errors

One common example of this involves the creation of invalid layouts:

  1. In branch A, we add a field F to a layout.

  2. In branch B, we add the same field F to the layout, but in a different place.

When we merge these branches, git merge will leave us with a layout that has 2 instances of field F. One in each of the positions from branch A and B. If we were to deploy this, it would fail validation, as duplicate entries are not permitted in layouts.

In contrast, semantic merge knows that this scenario will cause a validation error. Instead of simply allowing the merge to go ahead, it will flag this as a merge conflict that must be resolved by the user. (Do you want the field in the position from branch A or B?)

When is Semantic Merge used?

In short, Gearset uses Semantic merge in many different places.

  • Some are essentially invisible:

    • Precision deployments and deployments involving layouts

    • 'Simplify differences' option in the comparison grid

  • Others will add a commit in the repository:

    • Merge conflict resolution

      • Commit message prefix - Gearset: Conflicts resolved

    • Merging feature branches into a release branch in pipelines

      • Commit message prefix - Merge pull request

    • Creating a PR that targets a branch linked to a static pipeline environment.

      • Commit message prefix - Gearset: Semantic reverse merge

    • Updating a branch that is the source branch for a PR that is open against a static pipeline environment.

      • Commit message prefix - Gearset: Semantic reverse merge

    • Completing a PR that targets a branch linked to a static pipeline environment. If git merge finds conflicts then Gearset will try a Semantic Merge instead. (we try git merge first in order to avoid adding more commits if we don't have to)

      • Commit message prefix - Gearset: Semantic reverse merge

Did this answer your question?