Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AltiusRupert/d4189fe5bbc2adc4b63c0f87f50b5944 to your computer and use it in GitHub Desktop.
Save AltiusRupert/d4189fe5bbc2adc4b63c0f87f50b5944 to your computer and use it in GitHub Desktop.
SFDX - Converting an existing Salesforce production org to DX and Github in 4 steps

Converting an existing Salesforce production org to SFDX and Github

0. Prerequisites

SFDX

  sfdx force:auth:web:login -a devhub -d

Github

1. Create a new Github repo

  • Use the sample
  • Create the new repo
  • Sync the repo locally : this folder should be for PROD only, and will use the master branch

2. Prepare the package.xml

  • Go to https://packagebuilder.herokuapp.com
  • Log in to the target Salesforce production environment
  • Select "Component Option" = "Wildcard Only"
  • Click "Get Components"
  • Copy the text displayed
  • Copy it into the local file in manifest/package.xml

3. Get source code from production

# This logs in, creates an alias and declares this user as the default use
# Replace <clientname> with the client's name
 
sfdx force:auth:web:login -a <clientname>-prod -s
sfdx force:source:retrieve -u <clientname>-prod -x manifest/package.xml

4. Commit source code to Github repo

  • In VSCode, go to the Source Control tab : it confirms that source control = Git
  • Declare the Github remote repo : in VSCode, open command palette and choose "Git: Add Remote". Call it 'origin' and entre the url of the Github repo, including your username and password, eg
https://username:password@github.com/<username>/<repo>
ex : https://AltiusRupert:123456@github.com/AltiusRupert/client-SPIT
  • Commit all code files with comment "initial commit" : this commits files locally
  • Sync to Github : click on the Sync icon next to "master" in the Source Control tab and sync will start
  • At the end of the sync, check the results in Github : the force-app/main/default folder has been populated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment