Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcelinollano/abceb250dbf541404f23f32c91798d43 to your computer and use it in GitHub Desktop.
Save marcelinollano/abceb250dbf541404f23f32c91798d43 to your computer and use it in GitHub Desktop.
SFDX Commands
--targetusername = -u (To specify a non-default scratch org)
--targetdevhubusername = -v (To specify a non-default Dev Hub org)
--setdefaultdevhubusername = -d
--setdefaultusername = -s
--instanceurl = -r
--setalias = -a
IMPORTANT:
1. You can use force:source:pull for scratch orgs only. If you’re synchronizing source to any other org, use the Metadata
API (force:mdapi:retrieve or force:mdapi:deploy).
2. The force:source:deploy, force:source:retrieve, and force:source:delete commands work on sandboxes, Developer Edition orgs,
and trial orgs, but not production orgs. For production orgs, continue to use force:mdapi:deploy and force:mdapi:retrieve.
----------------------------------------------------------------------------------------
HELP
sfdx force:org:create --help
sfdx force:doc:commands:list
CREATE PROJECT
sfdx force:project:create --projectname mywork
sfdx force:project:create --projectname myproject --manifest
LOGIN
sfdx force:auth:web:login --setdefaultdevhubusername
sfdx force:auth:web:login --setdefaultdevhubusername --setalias DevHub
sfdx force:auth:web:login --setalias sandbox1 --instanceurl https://test.salesforce.com
LOGOUT
sfdx force:auth:logout -u [email protected]
sfdx force:auth:logout -a --noprompt (Log out all connected orgs)
CREATE DEFAULT SCRATCH ORG
sfdx force:org:create -f config/project-scratch-def.json --setalias sonalpsadevscratch --durationdays 30 --setdefaultusername
GET/SET local values for the project directory
sfdx force:config:list
sfdx force:config:get defaultusername defaultdevhubusername --json
sfdx force:config:set name=<value>
sfdx force:config:set instanceUrl=
sfdx force:config:set [email protected] (---> Set default username)
sfdx force:config:set [email protected] (---> Set default Dev Hub org)
SET ALIAS
sfdx force:alias:set [email protected]
OPEN DEFAULT ORG
sfdx force:org:open
sfdx force:org:open -u <username/alias>
DISPLAY ALL ORGS
sfdx force:org:list
sfdx force:org:list --clean (To remove non-active scratch orgs from the list)
DELETE SCRATCH ORG
sfdx force:org:delete -u tempTest
PUSH CODE To SCRATCH ORG
sfdx force:source:status
sfdx force:source:push
sfdx force:source:push --targetusername my-other-scratch-org
sfdx force:source:push --forceoverwrite
PULL CODE From SCRATCH ORG
sfdx force:source:status
sfdx force:source:pull
sfdx force:source:pull --forceoverwrite
VIEW LOCAL CHANGES
sfdx force:source:status --local
DEPLOY SINGLE FILE
sfdx force:source:deploy --loglevel fatal --sourcepath /Users/sonal/gsinternal-sfdx/force-app/main/default/classes/PSADataCreate.cls
sfdx force:source:deploy -p force-app/main/default/aura
sfdx force:source:deploy -p force-app -u [email protected]
RETRIEVE FILES
sfdx force:source:retrieve -p /Users/sonal/WebstormProjects/cg_salesforce/force-app/main/default/objects/CampaignMember/fields
sfdx force:source:retrieve -m ApexClass
sfdx force:source:retrieve -x path/to/package.xml
PACKAGE.XML
Create package.xml and save it in root directory.
Create folder mdapipkg in root directory.
sfdx force:mdapi:retrieve -r ./mdapipkg -u [email protected] -k ./package.xml
unzip mdapipkg/unpackaged.zip -d mdapipkg
Extract the zip file (mdapipkg/unpackaged/...)
sfdx force:mdapi:convert --rootdir mdapipkg
To deploy code in sandbox:
sfdx force:source:convert -d mdapi_output_dir --packagename [package name here]
sfdx force:mdapi:deploy --deploydir mdapi_output_dir --targetusername [email protected]
sfdx force:mdapi:deploy -w 1 -f mdZip/metadata.zip -u ${targetusernameOrAlias}
REFERENCES:
https://medium.com/@djrzo4/salesforcedx-123cc383a27e
sfdx force:source:retrieve -m PermissionSet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment