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
composer gitattributes
composer dev-tools 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:
composer 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. - Deduplicates equivalent entries and sorts them (directories before files, then alphabetically).
- 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.