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/attributesProject information
- Ecosystem: Scaffolding
- By aaron gil martinez on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
First release!
Development version: 1.0.x-dev updated 28 Oct 2026 at 08:18 UTC

