2

Git doesn't really work well for large binary files. And it's better to use git-annex, git-lfs etc for them. I want to ensure I am reminded about this fact any time I try to add/commit a large binary file. I know that GitHub already warns if a file is larger than their limit. However, I want the solution to not rely on GitHub.

So, my question is -- Is it possible to specify (preferably in gitconfig, although even specifying it per repository is okay) that I want to be warned any time I add/commit a file larger than a pre-defined size?

Sinatra
  • 820
  • 6
  • 13

1 Answers1

3

You can discourage committing large files with a pre-commit hook. The hook can reject a commit if any staged file is too large.

Here's one sample implementation: https://gist.github.com/LukasKnuth/1839424

If you want to bypass the check and commit anyway, specify '--no-verify' with 'git commit'.

  • Thank you. I found another SO question (http://stackoverflow.com/questions/7147699/limiting-file-size-in-git-repository) about the same. So, I'm marking my question a duplicate. – Sinatra Apr 09 '15 at 01:28