Download Salesforce CLI from https://developer.salesforce.com/tools/sfdxcli
Use visualstudio code editor (https://code.visualstudio.com/)
Install SFDX Plugin from salesforce on VisualStudio Code(https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode)
Clone the current repository from git and CD into the project root
Example to push all code from chapter 1 to scratch org start by changing directory using cd chapter1
and then following below commands
Authenticate to the DevHub using the below command
$ sfdx force:auth:web:login -d -a DevHub
Set your Devhub as default Dev hub globally .You will need to knpw your Devhub Username/alias for this
$ sfdx force:config:set defaultdevhubusername=DevHub -g
## create a scratch org for this branch . Total of 30 days for the scratch org created
$ sfdx force:org:create -s -f config/project-scratch-def.json -d 30 -a scratch_org
$ sfdx force:config:set defaultusername=scratch_org
$ sfdx force:source:push
$ sfdx force:org:open
$ sfdx force:source:push
Pull source from scratch org to the local folder if you make any code and config changes in scratch org
If you are doing any dev in scratch org including config and set up you can pull in your local src folder using below
$ sfdx force:source:pull
For this one will have to first authenticate to the Dev org where the Source Code will be deployed
Run the below command for authenticating to Devorg
$ sfdx force:auth:web:login -d -a Devorg
Once authenticated to push the source code to the Devorg run the below command.
The below converts the source to the Metadata API format from DX source format
$ sfdx force:source:convert -d mdapi_output_dir
Deploy the code to the Devorg
$ sfdx force:mdapi:deploy --deploydir mdapi_output_dir -u Devorg -w 3 --testlevel RunAllTestsInOrg
Your scratch can be available for 30 days and there is no need for them to delete .However if you have too many scratch orgs and running out of limits you can delete it using the below command . You will need username or the alias .
$ sfdx force:org:delete -u <username/alias>
$ code .
CLI reference Guide (https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm)
SFDX Developer Guide
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_develop.htm
This is because your user in the DevHub org does not have the DevHub Permission set assigned .Request your salesforce admin to give you access to this permission set in your DevHub org .