0

noob question from someone who just started using VSCode and SFDX for Salesforce development.

When you make changes to a project, git tracks those changes, this is nothing new. But when you want to revert changes, vscode removes those changes locally but the changes remain inside the org. How do I click the revert button on vscode and delete the files locally as well as inside the org?

Thanks for your time.

1 Answer 1

0

Depends on what files you're talking about, what org you're working against, and how much the org matches your source (if it's not a scratch org).

If you're utilizing scratch orgs, you can use sfdx force:source:push to sync those changes to the scratch org. If you feel it's gotten messy - you can also discard it and spin up a new one with your local as the truth.

If you're working on a non-scratch org, there's some considerations.

  • Is the metadata in the org the same as source or are multiple people working out of it?
  • Is it old or will it continue to be used?
  • Do you know what files were removed (assuming you already used git to revert the changes)
  • Is it a lot of things to delete?

If it's a couple classes or things that delete easily

  • In VS Code, you can right click on a file a select SFDX: Delete this from Project and Org.
  • Use the CLI and specify the file: sfdx force:source:delete -u orgAlias -p force-app/main/default/class/MyClassToDelete.cls.

Otherwise, if it's a bunch of files with dependencies, it might make sense to build a destructiveChanges.xml and utilize sfdx force:mdapi:deploy -d /pathToDestructivePackage. Make sure that a package.xml that contains no compnents to deploy is in that path along with your destructiveChanges.xml that does specify the files to delete.

The good news is that what I described for scratch orgs above is in beta with Summer '20 for developer and developer pro sandboxes. Soon you may be able to do the same as I described above with Scratch orgs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .