Skip to content

.forceignore does not seem to match patterns per .gitignore specification #3345

@jonathanmorris180

Description

@jonathanmorris180

Summary

.forceignore does not seem to match patterns per the .gitignore specification. When **/*.md is added to .forceignore, it also ignores .md-meta.xml files.

Steps To Reproduce

  1. Create a new empty repository:
sf project generate --name test
cd test
git init
git add . && git commit -m "initial commit"
  1. Add **/*.md to .forceignore and .gitignore: echo '**/*.md' > .forceignore && echo '**/*.md' > .gitignore
  2. Create a new test file:
mkdir -p force-app/main/default/customMetadata && touch force-app/main/default/customMetadata/test.md-meta.xml
  1. Notice that the test file is NOT excluded by git when running git status
  2. Auth to an org and pull a custom metadata file: sf project retrieve start -m "CustomMetadata:Some.Record"
  3. Notice that the file is not pulled:
 Retrieving v64.0 metadata from <org> using the v64.0 SOAP API

 ✔ Preparing retrieve request 8ms
 ✔ Sending request to org 264ms
 ✔ Waiting for the org to respond 345ms
 ✔ Done 0ms

 Status: Succeeded
 Elapsed Time: 612ms

 ›   Warning: Nothing retrieved
  1. Remove the pattern from .forceignore: echo "" > .forceignore
  2. Run the command again
  3. Notice that the file is pulled

Expected result

The CLI should not ignore .md-meta.xml files when **/*.md is added to .forceignore as this is not a correct pattern match (git does not do this).

Actual result

The CLI ignores .md-meta.xml files when **/*.md is added to .forceignore.

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.96.4",
  "nodeVersion": "node-v22.17.0",
  "osVersion": "Darwin 24.5.0",
  "rootPath": "/Users/jonathanmorris/.local/share/sf/client/2.96.4-f8aa88b",
  "shell": "zsh",
  "pluginVersions": [
    "@jedi/sf-jedi-plugin 4.0.0 (link) /Users/jonathanmorris/Documents/repos/sf-jedi-plugin",
    "@muenzpraeger/sfdx-plugin 0.5.0 (user) published 1889 days ago (Tue May 12 2020)",
    "@oclif/plugin-autocomplete 3.2.31 (core)",
    "@oclif/plugin-commands 4.1.26 (core)",
    "@oclif/plugin-help 6.2.29 (core)",
    "@oclif/plugin-not-found 3.2.57 (core)",
    "@oclif/plugin-plugins 5.4.43 (core)",
    "@oclif/plugin-search 1.2.25 (core)",
    "@oclif/plugin-update 4.6.45 (core)",
    "@oclif/plugin-version 2.2.30 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.42 (core)",
    "@oclif/plugin-which 3.2.37 (core)",
    "@salesforce/cli 2.96.4 (core)",
    "agent 1.23.2 (core)",
    "apex 3.6.19 (core)",
    "api 1.3.3 (core)",
    "auth 3.7.4 (core)",
    "code-analyzer 5.2.2 (user) published 20 days ago (Tue Jun 24 2025)",
    "data 4.0.42 (core)",
    "deploy-retrieve 3.22.27 (core)",
    "dev 2.5.1 (user) published 237 days ago (Tue Nov 19 2024)",
    "info 3.4.72 (core)",
    "limits 3.3.58 (core)",
    "marketplace 1.3.8 (core)",
    "org 5.9.2 (core)",
    "packaging 2.18.0 (core)",
    "schema 3.3.69 (core)",
    "settings 2.4.33 (core)",
    "sobject 1.4.63 (core)",
    "telemetry 3.6.45 (core)",
    "templates 56.3.53 (core)",
    "trust 3.7.107 (core)",
    "user 3.6.27 (core)",
    "@salesforce/sfdx-scanner 4.12.0 (user) published 76 days ago (Tue Apr 29 2025)",
    "sfdmu 4.38.0 (user) published 197 days ago (Sun Dec 29 2024)"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a bugvalidatedVersion information for this issue has been validated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions