I sometimes deploy metadata to Scratch Orgs, which I then want to pull into my sfdx source tree.

For example, I might be migrating metadata from a sandbox into the scratch org to package it with Unlocked Packaging. I can get the metadata into my source directory using sfdx, but sometimes a tool like Gearset is better because it lets me pick out the items I need. Gearset deploys into the scratch org, then I want to do a pull.

Or, I might be using Metadata.DeployContainer from Apex to create Metadata records in the scratch org. They then need to be pulled down and become part of the package.

In both cases, sfdx pull seems to ignore this metadata.

I can work around by going and editing each item, saving it without any changes. This touch seems to get sfdx to notice them.

Is this expected behaviour? Is there any way around it? Having to touch every item before pulling it is really laborious.

  • 1
    Have you tried working with SFDX:force:retrieve command? Using the flag -m can help you specify only the metadata type you want to retrieve and then package
    – sfdx bomb
    Commented Feb 12, 2020 at 17:00
  • Thanks - that's a reasonable thing to suggest, but if I need to import 100 components, it's a bit long-winded. Unless I use Gearset to generate a package.xml, then source:retrieve that. But that's still more steps than I would ideally like
    – Aidan
    Commented Feb 13, 2020 at 13:13

1 Answer 1


For now, yes (note: no idea when/if this will change). The Metadata Tracking feature applies to changes made within the Scratch Org itself. If you're using Gearset, you should be able to merge from an org to a source control system (this is how our Deployment Administrator uses Gearset in some emergency use cases). I believe this documentation should help you. Your desired source flow should be Source Org -> Source Control -> Scratch Org. After all, your source control is meant to be the Source of Truth in Salesforce development. As a bonus, you will also be able to easily build your Unlocked Packages using this route.

  • Thanks! I don't understand the rationale for the metadata tracking working like this. Have you ever seen any docs about it? I still don't really like the solution of deploying to source control with Gearset because that puts a whole load of commits into my repo when I'm doing one big thing, importing functionality X. I guess I'm just on the fringes of the normal use cases here
    – Aidan
    Commented Feb 13, 2020 at 13:11

You must log in to answer this question.

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