Skip to content

Issue with check-added-large-files and LFS directory #1253

@Maxioum

Description

@Maxioum

I am using the following pre-commit-config.yaml:

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      - id: check-added-large-files

This correctly prevents adding files larger than 500 KB.

With the following .gitattributes:

large_files/large_file.db filter=lfs diff=lfs merge=lfs -text

I am able to commit large_file.db successfully.

Issue:

If i delete .gitattribute and run :

git lfs track ./large_files/

This generates a new .gitattributes:

large_files/ filter=lfs diff=lfs merge=lfs -text

In this case, pre-commit prevents committing files inside large_files/, even though they are tracked by Git LFS.

Output of git lfs status --porcelain

A  .gitattributes
A  .pre-commit-config.yaml
A  large_files/large_file.db
A  large_files/large_file2.db

Environment
Git version: git version 2.51.2.windows.1
pre-commit version: pre-commit 4.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions