You can use in two ways.
-
Directly as the pre-commit hook in your .git/hooks folder.
-
With Husky by updating your package.json with:
"husky": {
"hooks": {
"pre-commit": "sh ./some-path/pre-commit-prevent-large-files.sh"
}
}
@guysmoilov wrote an awesome installer script over here that means this hook will be added to all future repos you clone; how cool!
Based on @kiwidamien's original gist here
pre-commit is "a framework for managing and maintaining multi-language pre-commit hooks" and has a hook you can plug-in called: check-added-large-files
. pre-commit is built with Python though, so you'll need Python installed.
Use a GitHub Aaction (see .yml file)
Thanks @Cyberbeni, updated