Scaffold Gitattributes Guard is a Composer plugin that protects custom .gitattributes rules from being overwritten by drupal/core-composer-scaffold.
Drupal's Composer scaffold process generates a .gitattributes file during composer install and composer update. This can overwrite project-specific rules, such as Git LFS mappings, merge strategies, or linguist settings.
This plugin preserves the project's tracked .gitattributes file while moving Drupal's generated attributes to the local .git/info/attributes file.
How it works
The plugin listens to the Drupal Composer scaffold events:
- Before scaffolding, it backs up the existing
.gitattributesfile. - After scaffolding, it moves the generated attributes to
.git/info/attributes. - It restores the original tracked
.gitattributesfile.
As a result:
- Custom project rules remain tracked in
.gitattributes. - Drupal's scaffold rules continue to apply locally.
- Drupal core updates do not create unnecessary changes to
.gitattributes. - Drupal-generated attributes remain local to the checkout and are not committed to Git.
Git gives the working-tree .gitattributes file higher precedence than .git/info/attributes, so project-specific rules take precedence over scaffold-generated rules.
Installation
Install the plugin as a development dependency:
composer require --dev drupal/scaffold_gitattributes_guardWhen Composer asks for permission to execute the plugin, allow it.
Requirements
- PHP 8.2 or later
- Composer 2.x
drupal/core-composer-scaffold9.x, 10.x, or 11.x
Usage
No configuration is required. After installation, the plugin runs automatically whenever Drupal's Composer scaffold process runs.
For example, the following tracked .gitattributes file remains unchanged:
# Project-specific rules *.po merge=po-merge docs/* linguist-documentationDrupal's generated attributes are stored locally in:
.git/info/attributes
Ask your assistant about Scaffold gitattributes guard
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.0.0-beta2 | Pre-release | Nov 10, 2026 | |||
| 1.0.0-beta1 | Pre-release | Oct 28, 2026 | |||
| 1.0.x-dev | Dev | Oct 8, 2026 |