It's Git. Merge conflicts happen. Let's take a look at common causes and paths to resolution.

Common Merge Conflict Causes

Stackbit runs your site and commits code and content changes against the preview branch. When you publish changes, those changes are automatically merged into your repo's default branch (usually main). Learn more about the publishing process.

The most likely cause of a conflict is that changes were merged into the main branch that were not also included on the preview branch. This will prevent Stackbit from being able to publish changes to your site.

This is only likely to happen when working locally on feature branches that merge into the main branch and fail to update preview.

If you don't believe anyone has worked on your code locally, it's possible that the merge conflict is a bug. Please contact support.

Resolving Conflicts

To resolve conflicts, you must first be working locally. Follow these steps:

  1. Checkout the main branch and pull:

    git checkout main
    git pull origin main
    
  2. Checkout preview and pull:

    git checkout preview
    git pull origin preview
    
  3. Merge main into preview:

    git merge main
    
  4. If you have conflicts, this is where they will arise. Resolve them, then commit. Learn more about merge conflicts.

    git add .
    git commit
    
  5. Push the preview branch.

    git push origin preview
    

Stackbit will be updated and able to publish shortly.

Tips for Staying in Sync

Because conflicts most frequently arise when main gets ahead of preview, it's important to keep preview in sync with main. When you work on a feature branch and merge into main, always remember to back-merge main into preview, and then push preview up to GitHub.

Suppose you opened a pull request (PR) against main with a new feature for your site. After you merge the PR, do the following:

  1. Checkout and update main locally:

    git checkout main
    git pull origin main
    
  2. Checkout and update preview locally:

    git checkout preview
    git pull origin preview
    
  3. Merge main into preview:

    git merge main
    
  4. Push preview:

    git push origin preview.