Skip to main content

How to use check-added-large-files hook with pre-commit

How to use and configure the hook check-added-large-files using pre-commit.

What is check-added-large-files #

The pre-commit hook check-added-large-files prevent you to commit files that are too large.

Careful: If you have git-lfs installed, lfs files will be ignored.

How to set it up #

To install this hook, open your .pre-commit-config.yaml file and add the following lines under the repos key:

- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.4.0 # Use the version you want
  hooks:
    - id: check-added-large-files
      args: ["--maxkb=2000"]

You may have noticed the args key. This is where you you can configure the hook.
In the example, I set up a maximum file size of 2MB. It could be removed if you want the default value, which is 500kB.

Tags

See Also

No results...