Retrieve Source

To retrieve metadata from the default org into your local project, use the SFDX: Retrieve Source from Org command. For non-source-tracked orgs, VS Code doesn’t automatically track changes to your org, so be sure to track the changes you retrieve in source control. Retrieving source from an org overwrites the local versions of the source files.

Retrieve source from org

You can retrieve source for a manifest, source files, directories, or folders:

  • In VS Code explorer or editor, right-click a manifest file and select SFDX: Retrieve Source in Manifest from Org.
  • With a manifest file open in the editor, open the Command Palette and run SFDX: Retrieve Source in Manifest from Org.
  • In VS Code explorer, right-click a source file or a directory and select SFDX: Retrieve Source from Org.
  • With a source file open in the editor, right-click in the editing pane and select SFDX: Retrieve This Source from Org.
  • With a source file open in the editor, open the Command Palette and run SFDX: Retrieve This Source from Org.

When you select an item to retrieve source, only the existing nested items in the directory structure are retrieved. For example, if you retrieve source for the classes folder, the Apex classes that currently exist in that directory are retrieved. The command doesn’t retrieve all the Apex classes in the org; it updates only the classes that exist in the folder. To retrieve a new Apex class, add that class (or all Apex classes) to a package.xml file and retrieve the source using the manifest file. You could also use a terminal to run sfdx force:source:retrieve --metadata ApexClass:YourApexClass.

You can also use the Org Browser to retrieve source.

The project structure after you retrieve source:

Org Browser