Skip to main content
100%

pre-commit hook for larger files

✓ Published0🌍 Public
ZZoeLeBlanc
Last edited Oct 14, 2023
Created on Jul 31, 2023

This example shows a Bash script that automatically detects files larger than 50 megabytes in a Git repository and adds them to the `.gitignore` file, unless they are already ignored. The script uses `git check-ignore` to verify whether each file is excluded, and `find` with `-print0` to handle file names containing spaces. It normalizes paths relative to the repository root before appending them to `.gitignore`, ensuring large files are not accidentally committed.

AI-generated description

Similar vizzes