3

How can configure my local git repository to prevent it to accept large files, which will later generate a error when trying to push to GitHub?

I've recently had a problem with a large file I've, by mistake, added to my local git repository. I've managed to fix it, by editing the commits in my local git and removing the file, through a series of git commands I don't remember right now. What I know it took a big slice of my time.

I'd like to prevent it to happen again, by somehow putting a block in my local git repository when I try to add a large file.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Marlon
  • 1,719
  • 3
  • 20
  • 42
  • Does this answer your question? [gitignore by file size?](https://stackoverflow.com/questions/4035779/gitignore-by-file-size) – Maarten Bodewes Aug 09 '22 at 19:40
  • I guess that you didn't find any results as you didn't type the word **ignore** in your search box. This is a problem with command line interfaces in general: you need to know the term to look for help, but you need the help to find the term. – Maarten Bodewes Aug 09 '22 at 19:40
  • 1
    Note that [this answer to that question](https://stackoverflow.com/a/70824800/589259) automates the process. – Maarten Bodewes Aug 09 '22 at 19:45
  • https://stackoverflow.com/a/39578014/7976758 , https://stackoverflow.com/a/53692461/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+prevent+adding+large+files – phd Aug 09 '22 at 19:48
  • @MaartenBodewes your suggestion does not helps me, because it only provides way to add all files currently in my files that are over 1g to .gitignore. I'd like something more permanent, wich wouldn't require me to run a .bat before every commit. – Marlon Aug 09 '22 at 19:59
  • Sorry @MaartenBodewes, now I've seen your last message. It might ideed solve my problem, I'll take a look. – Marlon Aug 09 '22 at 20:00
  • My bad as well, I posted the dupe link, and then I asked myself if this would automate it, and then I found that indeed the answer was there. So, yeah, I got lucky there as well. Anyway, I hope it solves your problem, do let us know! – Maarten Bodewes Aug 09 '22 at 20:38

0 Answers0