2.8 KiB
| description | allowed-tools | argument-hint | |
|---|---|---|---|
| Reset source tracking for the target org — tells the CLI to forget all tracked changes so the next push/pull treats the full org as new state. Destructive on shared sandboxes. Requires explicit confirmation before executing. |
|
[--target-org <alias>] |
WARNING — Destructive operation. Resetting source tracking tells the SF CLI to forget every tracked change between your local project and the org. After reset:
- A subsequent
sf project deploy pushwill treat all local metadata as new and deploy everything. - A subsequent
sf project retrieve startwill treat all org metadata as new and retrieve everything. - On a shared sandbox, this can trigger unintended mass deploys or retrieves that overwrite other developers' in-progress work.
Only proceed if you are on a personal scratch org or developer sandbox that you own.
Workflow
-
Resolve the target org. Parse
$ARGUMENTSfor--target-org <alias>. If not supplied, find the project's default:sf config get target-org --jsonExtract the
valuefield. If no default is set, ask the user: "Which org alias should source tracking be reset for?" -
Confirm the target. Display the resolved alias clearly, e.g.:
Target org:
myDevSandboxResetting source tracking is destructive on shared sandboxes. Typeyes, reset source tracking for myDevSandboxto continue, or anything else to cancel.Wait for the user's reply. If the response does not match
yes, reset source tracking for <alias>(case-insensitive), print "Cancelled — no changes made." and stop. -
Execute the reset:
sf project reset tracking --target-org <alias> --jsonParse the JSON result. On success the
statusfield is0andresultis an empty object{}. -
Report outcome. On success, print:
Source tracking reset for
<alias>. The CLI has cleared its local tracking state.On failure (non-zero status or an
errorkey in the JSON), surface the error message verbatim so the user can diagnose. -
Post-reset guidance. Recommend previewing the full diff before deploying:
Run
sf project deploy preview --target-org <alias> --jsonto review everything that will be pushed to the org before you deploy.
Rules
- Always use
--jsononsfcommands so you can parse outcomes programmatically. - Do NOT skip the confirmation gate under any circumstances, even if the user says "just do it".
- Do NOT chain the reset into an immediate deploy or retrieve without a separate user confirmation.
- If the command fails with
SourceTrackingErroror a locked-tracking message, suggestsf project reset tracking --no-prompt --target-org <alias> --jsonas a fallback (this bypasses the CLI's own prompt when one exists), but re-confirm with the user first.