retrieve Commands
retrieve metadata (Beta)
Description for retrieve metadata
You must run this command from within a project.
This command doesn't support source-tracking. The source you retrieve overwrites the corresponding source files in your local project. This command doesn’t attempt to merge the source from your org with your local source files.
To retrieve multiple metadata components, either use multiple --metadata <name> flags or use a single --metadata flag with multiple names separated by spaces. Enclose names that contain spaces in one set of double quotes. The same syntax applies to --manifest and --source-dir.
Examples for retrieve metadata
Retrieve the source files in a directory:
Retrieve a specific Apex class and the objects whose source is in a directory (both examples are equivalent):
Retrieve all Apex classes:
Retrieve a specific Apex class:
Retrieve all custom objects and Apex classes (both examples are equivalent):
Retrieve all metadata components listed in a manifest:
Retrieve metadata from a package:
Retrieve metadata from multiple packages, one of which has a space in its name (both examples are equivalent):
Usage
- sf retrieve metadata
- [--json]
- [-a API-VERSION]
- [-x MANIFEST]
- [-m METADATA]
- [-n PACKAGE-NAME]
- [-d SOURCE-DIR]
- [-o TARGET-ORG]
- [-w WAIT]
Flags
- --json
- Optional
-
Format output as json.
- Type: boolean
- -a | --api-version API-VERSION
- Optional
-
Target API version for the retrieve.
Use this flag to override the default API version, which is the latest version supported the CLI, with the API version in your package.xml file.
- Type: option
- -x | --manifest MANIFEST
- Optional
-
File path for the manifest (package.xml) that specifies the components to retrieve.
If you specify this parameter, don’t specify --metadata or --source-dir.
- Type: option
- -m | --metadata METADATA
- Optional
-
Metadata component names to retrieve.
- Type: option
- -n | --package-name PACKAGE-NAME
- Optional
-
Package names to retrieve.
- Type: option
- -d | --source-dir SOURCE-DIR
- Optional
-
File paths for source to retrieve from the org.
The supplied paths can be to a single file (in which case the operation is applied to only one file) or to a folder (in which case the operation is applied to all source files in the directory and its subdirectories).
- Type: option
- -o | --target-org TARGET-ORG
- Optional
-
Login username or alias for the target org.
Overrides your default org.
- Type: option
- -w | --wait WAIT
- Optional
-
Number of minutes to wait for the command to complete and display results to the terminal window.
If the command continues to run after the wait period, the CLI returns control of the terminal window to you.
- Type: option
- Default value: 33 minutes