Diff and merge content with contentful-merge
Diff and merge content with contentful-merge
Requirements
- A (free) Contentful account
- Locally installed
contentful-merge - The environments to compare must have identical content models. (Sync content models with help of the Merge App or the merge commands of Contentful-CLI
- A CDA and a CMA token with access granted to all environments to compare.
What is contentful-merge?
The contentful-merge CLI tool allows you to diff and merge entries across environments in a Contentful space. It can be used to create a changeset of all entry differences between two environments, and to apply this changeset to another environment, thereby effectively syncing the content of two environments.
Diff content between environments
To diff content between environments, run the following command:
This returns an output that informs you about all added, updated and deleted entries:
To see a more detailed overview of all changes, view the newly created changeset file which holds all relevant information in a machine-readable JSON format.
Merge content between environments
To merge content between environments, run the following command:
where:
- The
fileparameter expects the path to a changeset file, which can be created with thecontentful-mergecreate command described in Compare content between environments. - The
environmentparameter expects the ID of the environment you want to apply the changeset to.
After confirming, the following output is returned:
Now the content of both of your environments is in sync.
Limitations
- Changesets are created based on the Content Delivery API, therefore only published content is taken into account.
Additional resources
contentful-mergeon github- The Contentful-CLI offers additional tooling to move content across spaces and environments, e.g. importing and exporting.