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)
I've updated the gist with all your feedback everything except one I'm not sure about (see below). Do you mind checking it looks OK now to you?
Do you mean in the example usage? e.g. it should be this?
"pre-commit": "!/bin/sh ./some-path/pre-commit-prevent-large-files.sh"