5

Is there a way in which I can make git not include files which exceed its 100MB file size-limit while adding them to commit?

eg. If I have a folder with a large file (say 2GB) and a few other small code snippets, is there a way in which I can only include the small snippets using 'git add .' and simply ignore large file?

EDIT-1 : Thanks to the comments on this question, I see the task can be accomplished using hooks on either the client or the server side to update the .gitignore file. However, I would like to know if there are simpler (like setting some flags, or an in-built setting) ways of doing this?

NightFury13
  • 761
  • 7
  • 19
  • 2
    Possible duplicate of [gitignore by file size?](http://stackoverflow.com/questions/4035779/gitignore-by-file-size) – Jeff Puckett May 27 '16 at 12:04
  • 3
    @JeffPuckettII Yeah, one could write simple pre-commit git hook that would do that – Oleksandr Kravchuk May 27 '16 at 12:06
  • [Here's another dupe](http://stackoverflow.com/questions/7147699/limiting-file-size-in-git-repository) that might provide guidance. In addition, there's always [the documentation](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks). – ghoti May 27 '16 at 12:11
  • `find . -size +1G | cat >> .gitignore` then make an alias/script or something to have it executed automatically before every `git` command. – meucaa May 27 '16 at 14:29
  • 1
    Thank you guys for the suggestions! Looks like there is no in-built way of doing this. I was hoping for a simple flag-setting like solution. Are you guys sure there exists no such direct solution? – NightFury13 May 27 '16 at 16:03

0 Answers0