Last active
July 5, 2017 17:40
-
-
Save akkartik/276b24044383f1578df5 to your computer and use it in GitHub Desktop.
A git pre-commit hook to not permit commits with files larger than 100MB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Github won't permit files larger than 100MB (https://help.github.com/articles/working-with-large-files); | |
# don't wait to realize this until you try to push a bunch of commits. | |
git diff --cached --name-only | | |
while read file | |
do | |
if [ $(du -m $file |cut -f 1) -ge 100 ] | |
then | |
echo Files too big: $file and maybe others | |
exit 1 | |
fi | |
done | |
# Don't add any other commands here. The 'exit' above will only exit the | |
# pipeline, and the exit status of the entire script is the exit status of the | |
# final command. I hate sh/bash. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment