Sub topic 15
Troubleshooting common tracking problems
This chapter assumes you know how deploy, retrieve, preview, conflicts, and reset work from earlier chapters. It gives a method for diagnosing tracking problems, then walks through the most common ones.
Start with the preview
Most tracking problems come down to one question: what does the CLI think has changed? Ask it before you change anything.
sf project deploy preview --target-org my-scratch
sf project retrieve preview --target-org my-scratchNeither command modifies the org or your files. Read the output for three things: components listed as changes, components listed as conflicts, and components you expected that are missing.
Common problems
| Symptom | Likely cause | What to do |
|---|---|---|
| Deploy says there is nothing to deploy | The file is excluded by `.forceignore`, or it sits outside a package directory in `sfdx-project.json` | Check the ignore patterns and the file path |
| The command asks for source flags, or reports no tracking | The org is not a tracked type, such as a production org or a sandbox without tracking | Use `--source-dir`, `--metadata`, or `--manifest` |
| Conflicts appear for files you did not touch | Someone changed them in the org, or line endings or formatting differ | Review the preview, then pick a direction |
| The same components keep showing as changed | The local and org histories no longer match | Reset tracking after reviewing the differences |
| A deleted or renamed component stays in the org | The delete was not pushed to the org | Check the preview for pending deletes and deploy |
| Wrong results after switching machines | Tracking state in `.sf` is local to one machine and one project | Reset tracking, or retrieve fresh |
Check the target org first
A surprising number of problems are the wrong org. Tracking state is stored per org, so a command aimed at a different alias reports a different set of changes.
sf org list
sf config get target-orgPass --target-org explicitly while you diagnose, so you know which org each command reads.
Resolving conflicts and resetting
When the preview lists conflicts, do not reach for --ignore-conflicts first. Decide which side is correct for each component. Retrieve the org version if the org change should win, or deploy your local version if yours should.
sf project deploy start --target-org my-scratch --ignore-conflictsUse that command only after you have reviewed the preview. It makes your local files overwrite the org.
If conflicts or phantom changes persist, the two histories probably disagree. Reset tracking:
sf project reset tracking --target-org my-scratchCheck your ignore rules
If a component never shows up, test whether a pattern matches it. Broad patterns such as **/__tests__/** can hide files you wanted to keep.
**/jsconfig.json
**/.eslintrc.json
**/__tests__/**Exercise
After pulling a colleague's branch, sf project deploy preview lists no changes, but you know you edited an Apex class. Name two things to check.
Show answer
First, check that the class path is not matched by a pattern in .forceignore. Second, check that the file is inside a package directory listed in sfdx-project.json. You should also confirm that --target-org points to the org you expect.