So I Nuked My Git History (And I'd Do It Again)
Look, I get it - deliberately erasing git history is like telling other developers you kick puppies for fun. But I’ve got what I think is a pretty solid excuse: this site is hosted on codeberg, and those folks are generously providing free hosting for open source stuff despite having limited resources.
The way Hugo sites work, I need two branches going - one with all my markdown source files, and another with the massive HTML output that actually serves the site. Keeping the full history of both is just… wasteful. Especially on someone else’s dime. So I’ve decided to periodically nuke the entire history as a courtesy to my hosts. Call it digital spring cleaning.
If you ever need to do something similarly blasphemous, here’s the ritual:
|
|
What’s happening here? You’re basically creating a temporary orphan branch1 (a branch with no parents or history), copying your current files into it with a fresh commit, deleting your old branch, renaming the temp branch to replace it, then forcing that change to your remote. It’s like moving into a brand new apartment but bringing all your furniture with you.
After running this, you’ll see your repository showing just a single commit in the web interface. And eventually, the actual disk space used should shrink significantly if your hosting platform shows that stat.
I’m fully aware this goes against the sacred commandments of version control. Yes, history is important. No, you shouldn’t normally do this. But for a personal blog on a free hosting service? I’m willing to bend the rules a bit. Sometimes practicality trumps purity.