This hook warns you before you accidentally commit large files to git. It's very hard to reverse such an accidental commit, so it's better to prevent it in advance.
Since you will likely want this script to run in all your git repos, a script is attached to add this hook to all git repos you create / clone in the future.
Of course, you can just download it directly to the hooks in an existing git repo.
If you find this script useful, you might enjoy our more heavy-duty project FastDS, which aims to make it easier to work with versioning in data science projects.
curl -L https://gist.github.com/guysmoilov/ddb3329e31b001c1e990e08394a08dc4/raw/install.sh | bash
The default limit is max 5MB per file. If you feel that your commit is a special case, you can always override the limit with:
GIT_FILE_SIZE_LIMIT=42000000 git commit -m "This commit is allowed file sizes up to 42MB"
- pre-commit : The hook itself
- install.sh : Installs this hook to your git template directory.
Adapted from: https://gist.github.com/benmccallum/28e4f216d9d72f5965133e6c43aaff6e
Thanks for the suggestion! It does seem more straightforward.
However, it looks like the behavior of
stat
is inconsistent in Mac vs. LinuxOn my mac it should be
stat -f %z $file
So I think to avoid complicating things I'll leave it as is.