Newer Version Available
Track Changes Between Your Project and Org
| You can enable source tracking in Developer and Developer Pro sandboxes only. |
| Source tracking in scratch orgs is available in: Professional, Enterprise, Performance, Unlimited, Database.com, and Developer Editions |
| User Permissions Needed | |
|---|---|
| To track changes between your project and a sandbox: | Manage Sandbox |
| To enable Source Tracking in sandboxes: | Customize Application |
- Automatically track changes to metadata components, saving you from tracking them manually.
- See changes pushed to a sandbox by other developers.
- Push or pull changed source.
- Identify and resolve conflicts between your local project and scratch org or sandbox before pushing or pulling source.
To see which metadata components support source tracking, check the Source Tracking column of the Metadata Coverage Report.
- Install the Salesforce CLI.
- Enable Dev Hub.
- Enable Source Tracking for Sandboxes.
- Create a DX Project.
- Create a scratch org or sandbox, or refresh a sandbox that was created before enabling source tracking for sandboxes.
How CLI Commands Support Source Tracking
While all the force:source:* commands support source-tracking, there are differences in how you use them.
The force:source:push|pull commands push or pull all changed source between your local project and the target org. The important word is all: you can’t choose specific source files to push or pull. The commands work on all the changed files.
In contrast, the force:source:deploy|retrieve commands give you more granular control. By specifying the appropriate parameter, you can deploy or retrieve specific metadata components, package directories, or manifest files. To ensure that your source tracking files are updated, you must specify the --tracksource parameter. This example retrieves the MyFabClass Apex class:
In general, we recommend that you use force:source:push|pull to reflect all changes between your local project and org together, rather than specific changes one by one. Pushing or pulling all changes at once ensures that the tracking files accurately reflect your current state. For this reason, the examples in the source tracking topics use force:source:push|pull and not force:source:deploy|retrieve.