The Gist That Keeps On Giving

I’m working with git and make a big boo-boo.

Now I’m facing a situation where I’ve deleted a local branch with all my work and there’s no backup on GitHub.

“This is git. There has got to be a version of this things still on my computer somewhere, right? RIGHT?!”

So I start searching online: “how to recover a deleted branch in git?”

A few results later, I find this gist.

Not one to copy/paste CLI commands straight off the internet (cough rm -rf / cough) I read through the script.

git reflog

Idk what that is, but yes, I should be flogging myself after what I just did.

What else is in here?

git checkout

Yeah that seems fine. What else?

git branch

Ok, that’s not dangerous.

Yeah I think I can give this a shot.

A few commands later and the work I thought was gone forever is restored to my computer. Hallelujah!

Now, one of the principle rules of the internet is: “Don’t read the comments.” But that’s where I go because this gist just saved my life.

And apparently not just mine. Other folks are saying the same thing:

And not just lives. Saving asses too:

And time:

One commenter even went so far as:

I love it!

Seeing as it saved my butt, I also commented on the gist.

And because I commented, I’ve since been subscribed to further comments on the gist. And you know what? I kinda like it. I haven’t unsubscribed yet. It’s so fun. Every so often I get a new email notification from someone who commented on the gist, pouring out their gratitude.

Spread the love. As Jeremy says in “Our Web”:

Tell someone that you liked something they put on the web. You’ll feel good. They’ll feel even better.