source Commands

Use the source commands to push and pull source to and from your scratch orgs, to see synchronization changes between your project and scratch orgs, and to prepare your source for deployment to non-scratch orgs.

source:convert

Converts source in a Salesforce DX project into source 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




The directory that contains the source to convert.

Type: directory
-d | --outputdir OUTPUTDIR
Optional




The output directory to export the Metadata API source to.

Type: directory
-n | --packagename PACKAGENAME
Optional




The name of the package to associate with the Metadata API source.

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

This command must be run in a project.

To convert Salesforce DX–formatted source into a format that you can deploy using Metadata API, run "sfdx force:source:convert". Then deploy the source using "sfdx force:mdapi:deploy".

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

Examples:

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: file
-r | --urlonly
Optional




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

Type: flag
-u | --targetusername TARGETUSERNAME
Optional




Username 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

This command must be run in a project.

If Force.com IDE 2 is installed, the file opens in an embedded browser within the IDE. If Force.com IDE 2 isn’t installed, 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




Username 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

This command must be run in 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 the scratch org to keep them in sync.

Command Syntax

sfdx force:source:push
[-w WAIT]
[-g]
[-f]
[-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
-g | --ignorewarnings
Optional




Completes the deployment even if warnings are generated.

Type: flag
-f | --forceoverwrite
Optional




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

Type: flag
-u | --targetusername TARGETUSERNAME
Optional




Username 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

This command must be run in 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: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




Username 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

This command must be run in a project.

Examples: