-
Not Synced
Git tracks all of the revisions
that you make to your software.
-
Not Synced
But did you know that with reflog
-
Not Synced
it also tracks the revisions
to your revisions?
-
Not Synced
(smooth music)
-
Not Synced
Users of Git first discover
-
Not Synced
that every commit
they make in a repository
-
Not Synced
is a recorded snapshot in time
that shows how the code base is progressing,
-
Not Synced
but more advanced users of Git
discover that the reflog
-
Not Synced
is keeping track of commits that are made
-
Not Synced
as well as commits that are discarded.
-
Not Synced
This provides a rolling buffer of 30 days
-
Not Synced
in which you can recover
from any mistake,
-
Not Synced
including detrimental ones
with the git reset command,
-
Not Synced
the deletion of a branch,
-
Not Synced
or possibly a rebase gone awry.
-
Not Synced
(music) Git reset is specific to each and every branch.
-
Not Synced
You'll notice, if you chose to inspect,
-
Not Synced
that in the .git folder
-
Not Synced
there's a subdirectory called logs.
-
Not Synced
Beneath there is a file specific to every branch that you have on your local repository.
-
Not Synced
Each of those logs is keeping track of the changes that you make,
-
Not Synced
both forward and backwards in direction.
-
Not Synced
The user interface to this
is the git reflog command.
-
Not Synced
It outputs the most recent history.
-
Not Synced
A paging mechanism allows you to go through older entries
-
Not Synced
that have transpired on the branch that you're currently checked out to.
-
Not Synced
Once you've run git reflog for the first time
-
Not Synced
and seen the historical events
that displays on screen,
-
Not Synced
you wonder what you can do with those.
-
Not Synced
Simply grab one of the seven character hashes that are displayed
-
Not Synced
and use that as a potential candidate for restoring your code base.
-
Not Synced
git reset --hard
to that hash.
-
Not Synced
The current branch is now forcefully switched
-
Not Synced
back to that historical point.
-
Not Synced
(music)
-
Not Synced
The linear history that git reflog provides
-
Not Synced
can be difficult to navigate.