You Too Can Be A Git Night King!

Who doesn’t love bringing things back to life?!?!

Now my third non-language micromaterial, this one focuses on recovering a deleted local branch in git.

Essentially if you have some work that you’ve completed and pushed somewhere remotely (or it’s stored on someone else’s computer), then you can always get a copy of the work back.

The situation I ran into was that I had a bunch of work I need, but it had only ever been on my local computer. I got a bit overzealous with cleaning up unused branches, and before I knew it, I had deleted the branch that I actually needed!

This is my favorite use case for the reflog.

reflog

We’ve got a list of all the previous “moves” in our local git project, so just find the one you want, and go back to it.

There isn’t any code checked into the project repo, just the documentation to take the learner step-by-step through the process. Like rebasing, the reflog is something that seems scary/advanced/arcane until you actually just use it a few times.

What is unfamiliar is difficult. What is familiar is easy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s