How to limit file size on commit?
问题 I'm fully aware of this question which technically makes this a duplicate but the answers only offer a solution on push , which would be too late for my requirements. Is there an option to limit the file size when committing? For example: file sizes above 500K would produce a warning. File sizes above 10M would stop the commit. 回答1: This pre-commit hook will do the file size check: .git/hooks/pre-commit #!/bin/sh hard_limit=$(git config hooks.filesizehardlimit) soft_limit=$(git config hooks