ETOOBUSY 🚀 minimal blogging for the impatient
Obliterating a Git commit is gold.
Sometimes you accidentally commit a change to a Git repository and you later want to literally obliterate (remove all traces) of it.
This happened to me a few days ago. I added and committed a few not-so-light files in the repository, only to figure out that they were duplicates a little after.
That post hit the nail right in the head.
By default (for me, at least!) Git repository have a reflog, so this is how the obliteration should work (blatantly copying from the original post, for sake of quick preservation):
# blow away last commit
git reset --hard HEAD^
# if you were on main branch, for example, kill that reflog
# and the HEAD reflog as well
# now git-prune will get rid of everything you don't want
# do a repack for good measure, then garbage collect
git repack -a -d
Thanks, Obliterating a Git commit!