Newer Version Available

This content describes an older version of this product. View Latest

Track Changes Between Your Project and Org

Run source tracking to see a list of components you create, update, or delete between your local project and a scratch org or sandbox.
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
In addition to listing the changes you make, source tracking makes it possible to:
  • 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.

Before working with source tracking, ensure that you complete these prerequisites.
  1. Install the Salesforce CLI.
  2. Enable Dev Hub.
  3. Enable Source Tracking for Sandboxes.
  4. Create a DX Project.
  5. 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.

In this section, the terms push and deploy are used interchangeably and have the same meaning: moving source from the local project to the target org. Similarly, pull and retrieve both mean moving source from the org to the local project.

Note

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.