In this post I will cover how to take configuration and code from an existing org and create a Salesforce DX project with it.

Steps

  1. Package up the config and code
  2. Authenicate with the Org
  3. Download the package
  4. Convert the package


Package up the config and code

Open the existing org and enter setup:

Setup > Package Manager > New > Add

Then select the configuration you want in your Salesforce DX Project

Authenicate with the Org

sfdx force:auth:web:login -s

This will open Salesforce in the browser, please log in to the org you created the package in.

Download the package

Before we download the package, we need a folder to store it in:

mkdir pkg

Now let’s download the package:

sfdx force:mdapi:retrieve -s -r ./pkg  -p package_name

And finally, unzip the package into the pkg folder:

cd pkg  
unzip unpackage.zip   

Convert the package

Go back to the project root folder and convert the package into a Salesforce DX format:

cd ..
sfdx force:mdapi:convert -r ./pkg

Now your org configuration has been converted.


Trailhead
Salesforce Documentation