Lesson learned

September 02, 2019 — Josh

git good before you dig yourself a hole you can't get out of
- me, circa 2019

I need to be more careful. In the past week I've messed up quite a few of my things. This post is a quick reflection on what I've done, so I can remember to be more thorough in the future.

So, what have I done?


About a week back I got myself a "beater laptop" so I could freely experiment with it and not worry about messing anything up. Well, it turns out that you still need to have enough sense to not completely break Windows. My plan was to play around with FreeBSD, and have it dual-booted with the default Windows 10 that came with the laptop. I kind of rushed through the installation, so the end result was (1) failure to actually install FreeBSD on the HDD, and (2) deleting a crucial partition of the Windows OS which led to it not working anymore. I felt like I had nothing to lose, until I ended up with a laptop that wouldn't boot.

Bonus: At that point I decided to just go with ol' Ubuntu, even though I was trying very hard to escape from it. As luck would have it, that didn't work out either and the laptop was still unresponsive (but hey, at least I was forced to get a little familiar with the BIOS!). This actually wasn't my fault, my USB crapped out completely so it wasn't working at all. But that's not all; Whilst trying to create a live USB, mostly from memory and in a hurry, I most likely "borked" my main laptop (a Mac, which I was trying very hard to preserve). "Borked" isn't my terminology -- that's what some guy at school told me I did when I asked him for help lmfao. I was using command line utilities to partition my USB and make it live (specifically dd, which every online guide mentions with the same energy as a student at Hogwarts would mention Voldemort), but since I had done this before I was not really proceeding with too much caution. What likely happened was that I somehow partitioned my actual HDD instead, which is definitely epic, proud of myself. Laptop still works as usual though -- it could've been worse.


This trip-up doesn't have reprocussions as costly as #1, but it appears that I was walking on a sentimental tightrope of whose existence I was not aware of for more than a year. You've likely heard of external hard drives -- they're typically used to back up your files. In order to actually back those files up, you'd typically use an application such as Time Machine or Carbon Copy Cloner (from now on, CCC). I've used both, and had negative experiences with both. Chances are, that's my fault! This time around, I was using CCC. It's important to note that I'm a generally nostalgic person, so I really do not enjoy losing memerobilia (whether physical or on the computer). I simply wanted to take all the files from my laptop, and copy them over to my hard drive -- and that's what I thought I was doing every time I used CCC to back up my stuff. I realized, though, that by default CCC attempts to recreate my laptop's current filesystem on the external hard drive. This means that all old files which are no longer on my laptop -- but are on the external drive -- get moved to some special folder called something like "CCC Safety Net", while CCC proceeds to make my drive look exactly like my laptop. Excuse me, but why are you deleting or moving anything on my destination drive!? All I asked for was to take something from my laptop and copy it over. Oh, it looks like that's actually an advanced option called "Don't delete anything". Shouldn't that be the default setting? Anyways, this was my fault, as I didn't read closely enough. I am quite upset now though, as the organization of my external drive is confusing at best. On the bright side, I think the files are all still there.


This situation, which inspired this post, was a royal mess which definitely took a few months off my life. Of course it had to do with git! This wasn't my first run-in with git -- I think I remember breaking a few repositories before, but they never had anything very important or substantial in them. This time, I broke the repo which I was using to host my site. The amount of time I spent working on my website far surpasses the time I've spent on any other single project. You can imagine the anguish you'd feel after potentially losing something you've put so much work into. Everyone always says, use version control to back up your code! That's all great until you actually corrupt your repository, at which point Google will lead you to results with a completely different sentiment "don't use git as your sole backup tool". But then again, that argument can be applied to anything. That's why the lesson I learned wasn't "don't trust git", but rather something else which I will properly phrase at the end of this post.

Anyways, here's what happened. I have a page on my site with a music player, and I store the music files in a folder within my repository (I then link to their location on GitHub in order to play them). Originally, I decided to use the wav files I already had on my computer, since I wanted to preserve sound quality. These files were huge though, like 20MB a piece. I've long replaced them with mp3 files, but my repository did not shrink in size. I realized that this is because the old files were still stored in the .git folder (specifically in a "packfile" which I guess is all of the old files compressed into one). So, I went on a quest to remove all of the wav files from existence, and hopefully rejuvinate my repository. Once again I trusted StackOverflow, and once again I "borked" it all. What was supposed to remove any traces of the wav files instead corrupted my repository. So, no head? What did I learn from all of this? Don't use git reset! Just kidding, what I actually learned was to not be stubborn and use a GUI :). No, I'm still kidding, I would never say something like that. I just learned that I'm an idiot. Somewhere along the line I messed up, and I think the repository was beyond repair. I rescued the commit history from an old backup (thanks CCC for not deleting it), created a fresh repository, and started anew. Rest in peace to those 129 commits, though.

What did I learn?

It's too easy to forget that everything is an abstraction. I feel like I understand my environment and the tools that I use, because I use them frequently enough to feel comfortable, but come on, I'm not a wizard yet and chances are neither are you. When feces hit the fan, it's time to stop being lazy and be VERY meticulous about your every move. From now on I will try my best to read documentation, and test things before I set them in stone (even the complex situations which will be very annoying to replicate). I will learn to not "bork", because I am not a doge. By the way, that guy never ended up helping very much (refer to #1 to find the original creator of the term "borked", which is who I'm referring to). I learned that I will never accept this reality: I cannot live my life forever programming by poking, eventually I NEED to understand how the things below me work. This is a general reflection now, I guess, cause whatever I just said barely applies to the above 3 scenarios. In regard to git specifically, I learned that git revert is quite nice in a pinch, and that I should read "Git Internals - Plumbing and Porcelain". You should probably read it too.

Thanks for reading!

Email me with your thoughts: josh [at] josh8 [dot] com