Sometimes we need to delete existing scratch org. Here is the command to delete it. Before we delete any scratch org we need to find the name of the org to delete.
Also read: Remove expired/deleted scratch orgs from vs code
List all connected orgs
Run the following salesforce cli command to list all the orgs connected to your cli.
sf org list --all
Delete scratch org
Now, runt the following command with scratch Org alias Name or with Username. after running this command, it will ask for confirmation, then type y to confirm.
sf org delete scratch -o alias/userName
Do the same thing using SFDX command, here it is.
sfdx org delete -o alias/userName
also Read: Most Frequently Used scratch org CommandsFlags:
- -o : Target org alias/ Username
Source:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_delete_scratch_unified