BFG repo cleaner
Committing things by accident, or changing your mind about what you want your repo to contain, even in its history. We’ve all been there. I’ve just never done anything about it until now, apart from
rm -rf .git && git init. It’s the only way to make sure, right?
Maybe by getting older, I also have more history built up I care about and want to keep. In my PhD I started collecting scripts into a repo, and grouped functionality into libaries, spun some of them out. If I hadn’t nuked the site from orbit a few times, that repo must have had 6 years of history by now. In any case, recently I really wanted to erase some stuff from history without erasing the history, and 300 nanoseconds later I discovered BFG Repo Cleaner. Does what it says on the tin, took less than a second. Feels like a detergent commercial, right?
Only thing that mystified me for a few minutes: it is important that the repo you checkout the mirror from is a bare repo, which means it has nothing checked out (‘on disk’), it’s just a .git dir containing the repo. Repo’s on Github are bare, and the BFG documentation being written with Github being the source repo doesn’t make that very clear.