synchronising Drupal 8 config to a new site

When trying to use the Drupal 8 configuration manager you will get to a point where the config from your developemnt site will not import into the production site because the UUID of both sites is not the same.This safety is built in to avoid importing the configuration froim the completely wrong site screwing up the site completely. So as long as the UUID of both sites is not the same you can not synchronise the config of both versions. So the base question is : how to copy the UUID from one site to another?

Get the UUID from the source site

Do an export of the config from the source site - the site containing the configuration that you want to move to the other site. Unzip the downloaded file and open the system.site.yml file. On the fist line you will find the UUID.

Clear the database of the target site

This step is not necessary if you are using a freshly installed site as the target site.

If you already have made some configuration on the target site, to avoid config conflicts, you need to clear the database. Use your favorite database manager and remove all tables from the database or remove the database and recreate it.

Copy all files from the source site

In order to be able to apply all configations, copy the content of the thems, modules and sites/default/files folders.

Import the UUID to the target site

Use drush 9 to set the UUID in the taget site by using the folowing command

drush config-set "system.site" uuid "af1b68f0-4570-4c09-a751-2eaef62c001e"

Of cource you need to replace the UUID in the command above with the one used by your source site.

Import the config

Your site is now ready to receive the configuration from the source site. Go to Development > Configuration Synchronisation > Import and upload the config file you exported on the source site. Click the Upload button and the file will be parsed. You will then be presented with the differences in configuration between both sites. You can now import all resulting in a site with exactly the same content as the source site. All content is not synchronised this way, which is exactly what we want.

Error?

If you get an error after importing the config and trying to synchronise telling you you need to delete entities of type Shortcut you can solve this by running the following command

drush ev '\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete();'

You can then try to synchronise again.