Getting My Git Together
Table of Contents
We all do stupid things sometimes. Some mistakes are stupider than others,
unfortunately. For instance, sometimes I forget to write a proper .gitignore.
Whoops. I always assumed that fixing it after the fact would be very difficult.
Not so!
I was forced to deal with my mistake when my gitea server started crashing due
to lack of memory. Unfortunately, this was not the point at which I realized
that the repo size was the problem. That only happened when, worried about all
the crashes, I tried uploading some backups of important repos to codeberg. This
is actually pretty straightforward with gitea dump. The resulting zip file
contains the repos in the "bare" git format, which I got to learn about for the
first time.
Once I actually went to upload the repos to codeberg, however, the good people of codeberg warned me that I was seriously abusing their usage limits; one of my repositories was 900MiB! Fortunately, they also have a very handy article that details how you can reduce the size.
The only thing that didn't work from the article was replacing the history on Codeberg. I'm not 100% sure why, but since I already had a backup in the form of the zip file, I chose to just delete the versions on codeberg and re-upload the much slimmer (6.7MiB) version of the repo. I did the same thing on my gitea server, and so far I haven't seen any more crashes due to memory exhaustion.
To avoid this situation in the future, I added a couple of lines to my
global .gitignore. I've also switched to
just running git commit instead of git commit -m so I can preview the staged
changes and cancel the commit if something looks wrong.