Newer Version Available
How to Exclude Source When Syncing or Converting
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, is excluded by default.
The .forceignore file excludes files when running force:source:push, force:source:pull, and force:source:status. For source:status, remote changes are checked against entries in the .forceignore file. Let’s say you added a class called HelloWorld.cls on the server and included an entry in .forceignore that matches the file name (such as HelloWorld.cls or HelloWorld.*). The source:status output omits the HelloWorld.cls.
Where to Put .forceignore
Be sure the paths you specify in .forceignore are relative to the directory containing the .forceignore file. 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. In this example, all paths are relative to the project root directory.
1# Specify a relative path to a directory from the project root
2helloWorld/main/default/classes
3
4# Specify a wildcard directory - any directory named “classes” is excluded
5**classes
6
7# Specify file extensions
8**.cls
9**.pdf
10
11# Specify a specific file
12helloWorld/main/default/HelloWorld.cls