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 .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:

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-export configuration to keep specific paths in exported archives.
  • Respects extra.gitattributes.no-export-ignore as an alias.
  • Preserves existing custom .gitattributes rules.
  • 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-run and --check render a diff against the normalized managed result before deciding whether to write.