[SalesForce] SFDX: Is it possible to push to a sandbox from VS Code

I have successfully connected VS Code and pushed to several different SF environments, including Trailhead, Developer, and Production. But I can't figure out how to push to a sandbox. It looks like you can't connect to a sandbox the same way you would with another org (using SFDX: Authorize an Org from the command palette), but when I do it directly from the command line
sfdx force:auth:web:login -r https://test.salesforce.com/
it seems to work (I get a message in terminal that I've Successfully authorized <mySandboxUsernam> with org ID <myOrgId>)

But after authorizing, if I try to right-click on a folder to deploy, I don't get a contextual menu option of SFDX: Deploy Source to Org as I would when authorized with other instances. Is there any way to push code to a sandbox? I don't mind doing it from the command line if that's the only way, but I can't find any documentation on how to do it.

Best Answer

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.