2 min episode 7 of 18
In this episode, we will take a look at another very interesting tool in Git, the Reflog.
With the Reflog, Git keeps a protocol of any HEAD pointer movements - when you commit, check out, reset, cherry-pick and so on.
Reflog can be accessed from the sidebar. If you cannot see it, you will need to switch it on in the Settings. To do that, go to Tower’s settings and check the “Show reflog in sidebar” checkbox.
Let’s create an example scenario so we can try out the Reflog in action. Let’s imagine that we did a Reset by mistake. Now, we’d like to undo this operation and get back the commits we deleted.
Let’s see if the Reflog can help! When you select it in the sidebar, you will see all the head pointer movements that happened in this branch. The last one is the entry with the Reset operation we did erroneously.
To undo this Reset, we can either drag & drop it onto the “Branches” label, or select the “Create new branch” menu item. Let’s give this branch a name, for example, “happy-ending” and finish with Create Branch.
Here we go - we’ve successfully recovered the deleted commits.