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
.gitattributesdrift without writing the file. --check- Exit with code
1when.gitattributesneeds 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-exportconfiguration to keep specific paths in exported archives. - Respects
extra.gitattributes.no-export-ignoreas an alias. - Preserves existing custom
.gitattributesrules. - Missing generated exclusions are prepended as defaults. Existing rules retain
order and repetitions, so later consumer
-export-ignoreor!export-ignoreoverrides 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-runand--checkrender a diff against the normalized managed result before deciding whether to write.