The Git Parable

I don’t sleep well, and frequently wake up around 2 AM.  Sometimes I’m tired and can go back to sleep. Other times I wake up and I’m UP so I usually code. One morning was sort of borderline, but I decided to get up and code anyway. I started building a little calculator app in Kotlin as practice for my thesis. I got it working with both enumerated and sealed class versions of the functions.

So then, since I need a GUI for my thesis, I started building a GUI for the calculator. It took days, but eventually I got TornadoFX, JavaFX, Kotlin, Gradle, and Intellij’s IDEA all playing together nicely. By this time I’ve been working on this thing for about 3 weeks? And the only backup (because I’m smart but a dumb ass at the same time) is that the project is saved in Dropbox.

So I decide it’s time to implement Git, at least for my own usage, even though I wasn’t going to put it on Github. So I type git init, and git add . and commit the whole thing. And then realize I did this without a .gitignore file, so I’ve now committed everything including builds, the .idea folder, etc. So, it’s about 3 AM by this point, so I pull up Oh Shit Git, because I know I’ve used that to get out of this situation before.

But because it’s 3 in the morning and I KNOW I’ve done this before, I skim the zine, and go and tell git to not follow everything. Well, technically I told git not to follow anything. Well technically I told git to DELETE everything. So I create a .gitignore file, figure out what I need in it, put it in the folder, type git add . again, and commit the change.

I think everything is fixed and go back to the IDE. But wait, it can’t find the src folder anymore. I am confused. So I go check the folder on the command line, and the damn thing contains .gitignore, the folders I told it to ignore, and nothing else.

So that’s when I panicked, and thought, “okay, I’ll just take it out of git, and that’ll fix everything.” (What can I say, it was 3 in the morning.) AND THEN I DELETED THE .git FOLDER.


And instantly the entire Git Parable lecture comes to mind and I realize I’ve pooched it horribly, and have destroyed any chance of saving this project. At that point the damage is done, I deleted it on the command line, so that sucker was not in the garbage can. So I go back to bed.

Now, I back shit up in Dropbox just in case. And a day later it dawned on me that paid Dropbox accounts include their own version control. So I got VERY lucky, and they still had the deleted files so I could recover them. The project no longer compiles, but I can see what was in the files, especially the build.gradle.kts file.

Which is a long way of explaining why the Git Parable is important, and hopefully by rewatching it, next time I panic at 3 in the morning, I won’t delete the damn .git folder.

Leave a comment

Your email address will not be published. Required fields are marked *