Newer Version Available

This content describes an older version of this product. View Latest

How to Exclude Source When Syncing or Converting

When syncing metadata between your local file system and a scratch org, you often have source files you want to exclude. Similarly, you often want to exclude certain files when converting source to Salesforce DX project format. In both cases, you can exclude individual files or all files in a specific directory.

Use your favorite text editor to create a .forceignore file to specify the files or directories you want to exclude. Any source file or directory that begins with a “dot,” such as .DS_Store or .sfdx, is excluded by default.

Where to Put .forceignore

For the .forceignore file to work its magic, you must put it in the proper location, depending on which command you are running.

  • Add the .forceignore file to the root of your project for force:source:push.
  • Add the file to the Metadata retrieve directory (with package.xml) for force:mdapi:convert.

Sample Syntax for .forceignore

The .forceignore file has similar functionality to .gitignore. Here are some options for indicating which source to exclude. All paths are relative to the project root directory.