2

How can I DECREASE the maximum file size that I can commit onto Git repository (or, at least, that I can push from my remote server onto a Github repository)?

I want to decrease it from the default 50/100MB of Github, to e.g. 10MB. In particular, when I

git commit -m "Message"

I would like Git to warn (or prohibit) me, saying that files x/y/z are too large.

Reason: I don't need to track such big files, but sometimes, accidentally, I forget to .gitignore them and they slow down the "git push" and "git pull" commands, a lot.

1000 thanks in advance.

tyrex
  • 8,208
  • 12
  • 43
  • 50
  • 3
    One way to do this is with a pre-commit hook. Take a look at [How to limit file size on commit?](https://stackoverflow.com/questions/39576257/how-to-limit-file-size-on-commit) – James Bernsen Sep 03 '18 at 21:17
  • Note that the suggestion by @JamesBernsen requires _every_ user to have the hook. – jhpratt Sep 03 '18 at 21:26

1 Answers1

2

This cannot be done on GitHub itself (over which you have no control)

You would need to do that locally, with this (for example) pre-commit hook, in order to check the size of the files part of your commit.
But that means it is a local-only workaround, that needs to be applied on each machine you or your colleagues are working on.

That differs from a private Git repo hosting server, where you can easily limit the size on the listener (an HTTPS one like NGiNX for example, with client_max_body_size )

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250