Skip to documentation

gitattributes

Manages .gitattributes export-ignore rules for leaner package archives.

Description

The gitattributes command adds export-ignore entries for repository-only files and directories to keep them out of Composer package archives.

Usage

cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" gitattributes
cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" gitattributes
vendor/bin/dev-tools gitattributes

Options

--dry-run
Preview managed .gitattributes drift without writing the file.
--check
Exit with code 1 when .gitattributes needs an update.
--interactive
Prompt before updating .gitattributes .
--json
Emit a structured machine-readable payload instead of the normal terminal output.
--pretty-json
Emit the same structured payload with indentation for terminal inspection.

Examples

Manage export-ignore rules:

cpx --skip-local "fast-forward/dev-tools:$DEV_TOOLS_VERSION" gitattributes

Exit Codes

Code Meaning
0 Success. Export-ignore rules synced.
1 Failure. Write error.

Behavior

  • Adds export-ignore entries for repository-only files and directories.
  • Only adds entries for paths that actually exist in the repository.
  • Respects extra.gitattributes.keep-in-export configuration to keep specific paths in exported archives.
  • Respects extra.gitattributes.no-export-ignore as an alias.
  • Preserves existing custom .gitattributes rules.
  • Missing generated exclusions are prepended as defaults. Existing rules retain order and repetitions, so later consumer -export-ignore or !export-ignore overrides remain effective. No-op and repeated merges retain the same effective attributes.
  • Explicit keep-in-export paths still remove matching simple positive exclusions; they do not rewrite arbitrary compound attribute rules or glob exceptions.
  • Uses CandidateProvider, ExistenceChecker, ExportIgnoreFilter, Merger, Reader, and Writer components from the GitAttributes namespace.
  • --dry-run and --check render a diff against the normalized managed result before deciding whether to write.
Search results