I used force:source:retrieve to retrieve the given list of components (classes, workflows etc) and committed the files to git. Now I want to deploy these components to higher environments like QA and Prod from Git.

force:source:deploy - I can't use this since it doesn't have the options like validate only or run local tests etc.. So I am planning to use force:source:convert to convert into mdapi format but even this does not have an option to convert a list of metadata, it converts all the source code in the root folder.

What are the options to convert given list of metadata (package.xml/list of files) to mdapi format and then deploy to sandbox/prod from git.

1 Answer 1


You can use .forceignore file to specify the files which you want to exclude while converting to metadata format.

From How to Exclude Source When Syncing or Converting documentation:

The .forceignore file excludes files when running the source commands: force:source:convert, force:source:push, force:source:pull, and force:source:status.

Let's say you have a DX project structure as below:


And that you want to exclude MySecondClass.cls from being converted into a metadata format. You can then include this file in the .forceignore file so that the output directory does not contain this entry. The entry in the .forceignore file should be then as below:


When you run the force:source:convert, the generated output metadata format directory will not contain MySecondClass* files or any entry in the generated package.xml.

  • Is there an option to only exclude during convert though? I have files I'd like to push/pull but just not convert e.g. permission sets Commented Jan 3, 2019 at 14:38
  • This also works for syncing between your local system and the scratch orgs as well. So as long as you have files specified in .forceignore, it will skip for any push/pull as well.
    – Jayant Das
    Commented Jan 3, 2019 at 14:39
  • Right - but in some cases, I only want to exclude a file from convert - I DO want it when I push/pull - e.g. I want permission sets for my scratch orgs, but don't want them pushed to my package org. But it doesn't seem like there are two forceignore options? Commented Jan 3, 2019 at 14:42
  • 2
    You're right. Unfortunately there's no separate files for that purpose. You will need to manipulate the file accordingly based on the type of operation.
    – Jayant Das
    Commented Jan 3, 2019 at 14:43
  • 2
    @ab0369 Unfortunately Yes, that's how you will be able to exclude the files not required to be part of metadata package. An alternate way would be to just copy only what is needed, in a separate folder and then execute the convert command from there. But in any case, you will need to manipulate things either this way or that way.
    – Jayant Das
    Commented Jan 3, 2019 at 15:57

You must log in to answer this question.

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