Newer Version Available

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

source Commands

Use the source commands to push and pull source to and from your scratch orgs, to deploy and retrieve source to and from non-source-tracked orgs, to see synchronization changes between your project and scratch orgs, and to convert your source to the metadata format for Metadata API deployments.

source:convert

Converts source-formatted files into metadata that you can deploy using Metadata API.

Command Syntax

sfdx force:source:convert
[-r ROOTDIR]
[-d OUTPUTDIR]
[-n PACKAGENAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-r | --rootdir ROOTDIR
Optional

A directory other than the default package directory that contains the source-formatted files to convert.

Type: directory
-d | --outputdir OUTPUTDIR
Optional

The output directory to store the Metadata API–formatted metadata files in.

Type: directory
-n | --packagename PACKAGENAME
Optional

The name of the package to associate with the metadata-formatted files.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:convert

NOTE: This command must be run from within a project.

To convert source-formatted files into the metadata format, so that you can deploy them using Metadata API, run "sfdx force:source:convert". Then deploy the metadata using "sfdx force:mdapi:deploy".

To convert Metadata API–formatted files into the source format, run "sfdx force:mdapi:convert".

To specify a package name that includes spaces, enclose the name in single quotes.

Examples:

source:delete (Beta)

Deletes source files from your project and from a non-source-tracked org, such as a sandbox.

This release contains a beta version of the source:delete command, which means it’s a high-quality feature with known limitations. The the source:delete command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the source:delete command in the Salesforce CLI New Command Feedback group in the Trailblazer Community.

Note

Command Syntax

sfdx force:source:delete
[-r]
[-w WAIT]
[-p SOURCEPATH]
[-m METADATA]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-r | --noprompt
Optional

Do not prompt for delete confirmation.

Type: flag
-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. The default is 33 minutes.

Type: minutes
Default value: 33
-p | --sourcepath SOURCEPATH
Optional

A comma-separated list of paths to the local metadata to delete. The supplied paths can be a single file (in which case the operation is applied to only one file) or a folder (in which case the operation is applied to all metadata types in the directory and its sub-directories).

If you specify this parameter, don’t specify --manifest or --metadata.

Type: filepath
-m | --metadata METADATA
Optional

A comma-separated list of names of metadata components to delete from your project and your org.

Type: string
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:delete

NOTE: This command must be run from within a project.

Use this command to delete components from orgs that don’t have source tracking, such as sandboxes.

To remove deleted items from scratch orgs, which have change tracking, use "sfdx force:source:push".

Examples:

source:deploy (Beta)

Deploys source to a non-source-tracked org, such as a sandbox.

This release contains a beta version of the source:deploy command, which means it’s a high-quality feature with known limitations. The the source:deploy command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the source:deploy command in the Salesforce CLI New Command Feedback group in the Trailblazer Community.

Note

Command Syntax

sfdx force:source:deploy
[-w WAIT]
[-m METADATA]
[-p SOURCEPATH]
[-x MANIFEST]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-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. The default is 33 minutes.

Type: minutes
Default value: 33
-m | --metadata METADATA
Optional

A comma-separated list of names of metadata components to deploy to the org.

Type: string
-p | --sourcepath SOURCEPATH
Optional

A comma-separated list of paths to the local source files to deploy. 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 metadata types in the directory and its sub-directories).

If you specify this parameter, don’t specify --manifest or --metadata.

Type: filepath
-x | --manifest MANIFEST
Optional

The complete path for the manifest (package.xml) file that specifies the components to deploy.

If you specify this parameter, don’t specify --metadata or --sourcepath.

Type: filepath
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:deploy

NOTE: This command must be run from within a project.

Use this command to deploy source to orgs that don’t have source tracking, such as sandboxes.

To push source to scratch orgs, which have change tracking, use "sfdx force:source:push".

To deploy metadata that’s in the Metadata API format, use "sfdx force:mdapi:deploy".

The source you deploy overwrites the corresponding metadata in your org. This command does not attempt to merge your source with the versions in your org.

If the comma-separated list you’re supplying contains spaces, enclose the entire comma-separated list in one set of double quotes.

Examples:

To deploy the source files in a directory:

To deploy a specific Apex class and the objects whose source is in a directory:

To deploy source files in a comma-separated list that contains spaces:

To deploy all Apex classes:

To deploy a specific Apex class:

To deploy all custom objects and Apex classes:

To deploy all Apex classes and two specific profiles (one of which has a space in its name):

To deploy all components listed in a manifest:

source:open

Opens the specified Lightning Page in Lightning App Builder. Lightning Page files have the suffix .flexipage-meta.xml, and are stored in the flexipages directory. If you specify a different type of file, this command opens your org’s home page.

Command Syntax

sfdx force:source:open
-f SOURCEFILE
[-r]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-f | --sourcefile SOURCEFILE
Required

File to edit.

Type: filepath
-r | --urlonly
Optional

Generate a navigation URL path, but don’t launch a browser-based editor.

Type: flag
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:open

NOTE: This command must be run from within a project.

The file opens in your default browser.

If no browser-based editor is available for the selected file, this command opens your org’s home page.

To generate a URL for the browser-based editor but not open the editor, use --urlonly.

Examples:

source:pull

Pulls changed source from the scratch org to your project to keep them in sync.

Command Syntax

sfdx force:source:pull
[-w WAIT]
[-f]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-w | --wait WAIT
Optional

The 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. The default is 33 minutes.

Type: minutes
Default value: 33
-f | --forceoverwrite
Optional

Runs the pull command even if conflicts exist. Changes in the scratch org overwrite changes in the project.

Type: flag
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:pull

NOTE: This command must be run from within a project.

If the command detects a conflict, it displays the conflicts but does not complete the process. After reviewing the conflict, rerun the command with the --forceoverwrite parameter.

source:push

Pushes changed source from your project to a scratch org to keep them in sync.

Command Syntax

sfdx force:source:push
[-f]
[-g]
[-w WAIT]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-f | --forceoverwrite
Optional

Runs the push command even if conflicts exist. Changes in the project overwrite changes in the scratch org.

Type: flag
-g | --ignorewarnings
Optional

Completes the deployment even if warnings are generated.

Type: flag
-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. The default is 33 minutes.

Type: minutes
Default value: 33
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:push

NOTE: This command must be run from within a project.

If the command detects a conflict, it displays the conflicts but does not complete the process. After reviewing the conflict, rerun the command with the --forceoverwrite parameter.

source:retrieve (Beta)

Retrieves source from a non-source-tracked org, such as a sandbox, to your local Salesforce DX project.

This release contains a beta version of the source:retrieve command, which means it’s a high-quality feature with known limitations. The the source:retrieve command isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the source:retrieve command in the Salesforce CLI New Command Feedback group in the Trailblazer Community.

Note

Command Syntax

sfdx force:source:retrieve
[-w WAIT]
[-x MANIFEST]
[-m METADATA]
[-p SOURCEPATH]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-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. The default is 33 minutes.

Type: minutes
Default value: 33
-x | --manifest MANIFEST
Optional

The complete path for the manifest (package.xml) file that specifies the components to retrieve.

If you specify this parameter, don’t specify --metadata or --sourcepath.

Type: filepath
-m | --metadata METADATA
Optional

A comma-separated list of names of metadata components to retrieve from the org.

Type: string
-p | --sourcepath SOURCEPATH
Optional

A comma-separated list of 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 sub-directories).

Type: filepath
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:retrieve

NOTE: This command must be run from within a project.

Use this command to retrieve source from orgs that don’t have source tracking, such as sandboxes.

To pull source from scratch orgs, which have change tracking, use "sfdx force:source:pull".

To retrieve metadata that’s in the Metadata API format, use "sfdx force:mdapi:retrieve".

The source you retrieve overwrites the corresponding source files in your local project. This command does not attempt to merge the source from your org with your local source files.

If the comma-separated list you’re supplying contains spaces, enclose the entire comma-separated list in one set of double quotes.

Examples:

To retrieve the source files in a directory:

To retrieve a specific Apex class and the objects whose source is in a directory:

To retrieve source files in a comma-separated list that contains spaces:

To retrieve all Apex classes:

To retrieve a specific Apex class:

To retrieve all custom objects and Apex classes:

To retrieve all Apex classes and two specific profiles (one of which has a space in its name):

To retrieve all metadata components listed in a manifest:

source:status

Lists changes that have been made locally, in a scratch org, or both.

Command Syntax

sfdx force:source:status
[-a]
[-l]
[-r]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-a | --all
Optional

Lists all the changes that have been made.

Type: flag
-l | --local
Optional

Lists the changes that have been made locally.

Type: flag
-r | --remote
Optional

Lists the changes that have been made in the scratch org.

Type: flag
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for source:status

NOTE: This command must be run from within a project.

Examples: