Skip to content
Versora

Manual

Inspection

Reflog

3 min read

On this page

Git records every movement of HEAD and of each branch: commits, checkouts, resets, merges, rebases, pulls, cherry-picks. That list is the reflog. A commit that disappeared from the graph after a hard reset, a rebase or a branch deletion stays in the reflog for quite a while, and you can recover it by creating a branch on it.

The reflog is local: it only exists in your clone and isn't included in a push.

Where to find it

  • Repository bar: clock icon ("Reflog — where HEAD has been (recover commits)").
  • Palette (Ctrl+P): "Reflog…" ("Where HEAD has been — recover lost commits").

Step by step: recover a lost commit

Example: you used Reset main to this commit › Hard — discard all changes… two commits down and realized you needed one of them.

  1. Open the reflog with the clock icon.
  2. Under Reference, leave HEAD (everything you did), or choose a local branch to see only its movements.
  3. Use Filter to find the entry by action, message or the start of the SHA. For example, type commit or part of the lost commit's summary.
  4. Each row shows the type of movement (commit, amend, checkout, reset, merge, rebase, pull, cherry-pick, revert, clone, branch), the action as git wrote it, the short SHA, the date and the commit's summary.
  5. On the row of the commit you want, click Create branch.
  6. In the Create branch here window ("Creates a branch at <sha>. It's the safest way to recover commits that ended up outside any branch."), type the Branch name, for example recupera-frete. Spaces become hyphens.
  7. Check Check out the new branch if you want to switch to it, and click Create.
  8. The commit shows up in the graph again, on the new branch.

An entry's actions

ActionWhat it does
Show in graph"Selects the commit in the graph" and closes the reflog. It only appears if the commit is in the graph.
not in graphBadge in place of Show in graph: "This commit isn't on any branch or tag shown in the graph". It's the sign of a lost commit.
Create branchCreates a branch at that point, optionally with a checkout.
Reset to here"Hard reset <current branch> to this point". Moves the current branch there and puts the files back the way they were at that moment.
Copy SHACopies the full SHA.

Reset to here

Moves the current branch (or HEAD, in detached HEAD) to a reflog entry, with a hard reset. It's useful for undoing a sequence of operations all at once, for example a rebase that went wrong.

  1. Click Reset to here on the entry from before the problem.
  2. Read the Reset <branch> to this point confirmation: "Moves <branch> to <sha> and puts the files back the way they were at that moment (hard reset). Uncommitted changes will be discarded — but you can undo this right afterwards."
  3. Click Reset to this point. While it runs, "Resetting to the reflog entry…" appears.

Caution

Reset to here always moves the checked-out branch, even when the list shows another branch's reflog in the Reference picker.

What Versora does in git

To read the list (up to the 1,000 most recent entries):

bash
git reflog show -n1000 --format=<fields> <reference> --

For the actions:

bash
git branch recupera-frete a1b2c3d       # Create branch
git checkout -b recupera-frete a1b2c3d  # Create branch, with "Check out the new branch"
git reset --hard a1b2c3d                # Reset to here

How to undo

  • Create branch: Ctrl+Z undoes the Create branch.
  • Reset to here: Ctrl+Z undoes the Reset to reflog entry. Before the reset, Versora keeps a copy of the changed files, and undo restores the branch and the files.

See Undo and redo.

Caveats and messages

  • "This reference has no movement history yet.": the branch or the repository is new, or the reflog was deleted.
  • "Nothing matches the filter.": no entry contains the filtered text.
  • Reflog entries expire: by default, git deletes unreachable entries after 30 days and the others after 90 days, during maintenance (git gc). Recover as soon as possible.

Tip

To roll back recent operations done in Versora, Ctrl+Z and the timeline are usually simpler. The reflog also covers what was done in the terminal or in other tools.

The reflog has no preference of its own and no company policy key.

See also