Syncing Content Fails due to Conflicts

Illustrated drawing of Amadeus Maxmimilian StadlerIllustrated drawing of Amadeus Maxmimilian Stadler

Amadeus Stadler

Published March 10, 2023

Since Mattrbld allows for collaboration, but this collaboration happens asynchronously, there could be cases where two users modify the same file within a project. In some rare cases, if two users modify the same line within a file between sync intervals, this may lead to a conflict. As outlined in the article on collaboration, Mattrbld is built in such a way to minimise the likelihood of such conflicts. Nonetheless, there are some rare cases, where they could happen.

In this article, you’ll learn what you can do if you are no longer able to sync your changes because of a merge conflict.

Avoiding Conflicts

The best way to deal with merge conflicts is to avoid them in the first place. This can be done by ensuring that you sync your changes whenever you’re done modifying a file. If you’d like to make sure those changes don’t fire a build process, you can make use of Mattrbld’s drafts functionality or add a [skip-ci] message in your message if your Git provider supports those.

Whenever you sync, Mattrbld first pulls all the changes that were made since the last sync to your device. The same happens whenever you open a project, or manually check for updates without pushing anything back.

Furthermore, you and your team members can make sure to not work on the same files at the same time, which generally shouldn’t happen that often. Even if it does, as long as you edit different fields, you should be fine.

Noticing Conflicts

In case a conflict does happen, Mattrbld will notify you in one of two ways:

  • If you manually initiated the syncing progress, you will immediately see a modal window containing the exact error message

  • If the sync process was initiated by Mattrbld, for example after opening a project, the status indicator in the sidebar will turn red and show an “Error” label. Clicking that label will open the modal with the error message.

You can use the information in the modal to either consult a developer on the next steps, or for resolving the conflicts yourself.

A screenshot of the error modal that shows up on sync conflicts in Mattrbld. It contains a generic text about something going wrong as well as a specific error message showing which files are conflicting and what exactly went wrong.A screenshot of the error modal that shows up on sync conflicts in Mattrbld. It contains a generic text about something going wrong as well as a specific error message showing which files are conflicting and what exactly went wrong.
Example of a sync conflict

As with any other sync-errors, you won’t be able to sync your changes until the conflict is resolved.

Dealing with Conflicts

Currently, Mattrbld doesn’t allow for manually performing a three-way-merge. The only option you have is to discard your local changes from the conflicting files listed in the data.filepaths array in the error message. To do so, simply close the error modal and open the sync modal and select “Discard changes” either from the right-click or three-dot menu of the given files.

To prevent the complete loss of your local changes, you can create duplicates of the conflicting files before discarding the changes made to them. You can duplicate files in Collections either by right-clicking them or using the three-dot menu and selecting “Duplicate”.

Another option is to select “Show changes” before discarding them and taking note of what you have locally changed in order to re-apply those changes after the sync completes.

After discarding the conflicting changes, you should be able to execute a sync normally and the status indicator in the sidebar should turn back green (or orange if you chose to not sync all your local changes).

In the unlikely event that this shouldn’t work, you can always delete the project and re-import it to “start fresh”—but keep in mind that this will get rid of all local changes that haven’t been synced yet, so it should only be done as a last resort.

Conclusion

Conflicts during data synchronisation can occur, but they are not the end of the world. Of course, they’re best avoided in the first place, but they can usually be resolved by discarding local changes.