The Branch Compare feature enables you to compare the changes between two branches – the Base branch (typically main) and the Compare branch (typically where the desired changes reside).
The base branch serves as the basis for comparison and also the location where any changes would be merged into (see Merging Branches for more information). The compare branch contains the changes you want to merge.
When comparing two branches, you can see:
Additional Resource: To learn how to compare branches using our new request in the Comparing Branches section in CMA, refer to our documentation. To compare branches via CLI, you can refer to the Compare Branches section in the guide on how to Compare and Merge Branches using the CLI.
There are three possible outcomes when comparing branches:
Let's learn how to Compare branches in Contentstack using a few use cases.
Consider a scenario where you need to redesign certain fields of your website without affecting anything in production. For example, you want to modify the Blog content type to have an Author reference field rather than an Author single line textbox. To achieve this, you can create a child branch called “development” that inherits all content types, entries, assets, languages, etc. from the main branch as is.
Next, you can make changes to the Blog content type within the development branch. Once you are satisfied with your changes, you can quickly check the differences between the development (compare) branch and the main (base) branch using Branch Compare CMA requests or CLI commands.
In this case, the differences will show a “modified” status since the Blog content type exists in both the base and compare branches, but you have made changes to their structure.
Consider a scenario where you need to add a new content type called Hero Banner to your website. You can start by creating a copy of your main branch. Your child branch can be called “redesign”, and it inherits all the content types, entries, assets, languages, etc. that were part of the main branch as is.
Now, you can create the new Hero Banner content type in the redesign branch without affecting the production (main) branch. Once you are satisfied with the development changes in the redesign branch, you can compare both the redesign and main branch using Branch Compare CMA requests or CLI commands.
The differences would show the status as:
For the above mentioned scenario, the status for the comparison will be “compare_only” since the new content type exists only in the compare branch.
Additional Resource: Once you are satisfied with the development changes between your branches, you can merge them. Learn more about Merging Branches.