How do I find a commit that has disappeared?
Look in the reflog: Git remembers every position every branch has held.
A commit goes missing from the history when nothing points at it any more — a branch was deleted, a reset moved past it, a rebase replaced it with a copy. The commit itself is still in the repository.
Reflog, in the sidebar’s Recovery group, lists where HEAD has
been — the last forty positions your working copy has held, newest first. Each
row says what moved it, a commit or a checkout or a reset, and under that the
HEAD@{n} selector, the commit’s short hash and when it happened.
It is for reading. Innesta will not make a branch at a commit you find there — it creates branches at the commit you are on and nowhere else — so recovering one by hand means copying the hash out of the row and, in a terminal:
git branch <name> <hash>
Copy Commit Hash — the button that appears at the right-hand end of the
row as you point at it, and the row’s context menu — copies the full hash,
which is the one to use. HEAD@{3} is a position in a list, and it will be some
other commit’s position after the next thing that moves HEAD.
Innesta’s own backups are the shorter route wherever they apply, and the three usual causes below say which do.
The three usual causes
- A deleted branch. Innesta also keeps its own backup — restoring a deleted branch is easier than the reflog.
- A hard reset. Innesta takes a restore backup first; see undoing a discard or reset.
- A rebase. The originals are not deleted, only orphaned. They are in the reflog under the branch’s old positions.
What the reflog cannot help with
Changes that were never committed. A discarded edit was never in a commit, so there is nothing for the reflog to have recorded — that one is Recovery, for as long as it keeps backups, and then gone.