SFDX: Is it possible to push to a sandbox from VS Code?

You need to use the force:source:deploy command (not available in the UI, as far as I can tell).

The basic syntax is as follows:

sfdx force:source:deploy -p source-dir/ -u username-or-alias

This should work fine from any terminal you open in VS Code.


sfdcfox layout out a good option. At time of writing, though, force:source:deploy is still in beta (as of Winter '19, API v45.0).

If you aren't comfortable with the beta designation, the other option is to convert from source form to metadata api form

sfdx force:source:convert -d targetDirectory

and then deploy using the metadata api

sfdx force:mdapi:deploy -d targetDirectory -u usernameOrAlias


I'm not sure how much of this is due to changes in the CLI and Extensions since Feb 2019, but what is now (May 2019) the case is:

  • The SFDX: Authorize an Org command in VS Code prompts for the login URL, allowing you to specify test.salesforce.org for a Sandbox.
  • The context menu item SFDX: Deploy Source to Org works for the defaultusername for the project. The SFDX: Authorize an Org command sets the authorized org to be the default for the project. But if you use sfdx force:auth:web:login -r https://test.salesforce.com --setdefaultusername you'll achieve the same result.
  • Towards the left side of the VS Code status bar, the default username for the current project is indicated (with a plug icon). You can click it and select a different, already-auth'd org to be the project default, auth to a new org and set it as the default, or spin up a new scratch org and have it become the default.