Coding⏱️ 2 min read📅 2026-05-30

How to Fix: Why are the following negated export-ignore pattern not working?

Negated export-ignore patterns not working in git archive

Quick Answer: The issue is that the negation operator (-) is not being applied correctly. Try using the following format: * export-ignore instead of * export-ignore. This should fix the issue and create expected dist artefact files.

In Git, the `export-ignore` pattern is used to exclude files from being included in a Git archive. However, when using negated export-ignore patterns, there are some edge cases that can lead to unexpected behavior.

🔍 Why This Happens

  • Git archives only include files that are not ignored by the `export-ignore` pattern. When a negated export-ignore pattern is used, it means that the file should be included in the archive. However, if the pattern is not correctly formatted or if there are multiple patterns with different effects, it can lead to unexpected behavior.

🔧 Proven Troubleshooting Steps

Method 1: Check Pattern Syntax

  1. Step 1: Verify that the negated export-ignore pattern is correctly formatted. The correct syntax for a negated export-ignore pattern is `-export-ignore` or `* -export-ignore `. Make sure to add quotes around the file pattern if it contains spaces.

Method 2: Use a Single Negated Pattern

  1. Step 1: Remove all negated export-ignore patterns and use a single pattern that includes the files you want to include in the archive. For example, `<* -export-ignore composer.json>` would include `composer.json` but exclude all other files.

✨ Wrapping Up

By following these steps, you should be able to resolve the issue with your negated export-ignore patterns and create a successful Git archive.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions