When working in Git, it is easy to lose track of commits and branches. You might check out another branch, run a reset, or delete something you should have kept. If you know the SHA, you can recover it. If you do not, you need tools to recall it.
git reflog is the primary command for recall. Reflog records every branch checkout, commit, reset, and merge. It is local to your repository. Run:
git reflog
Each entry shows an index, a commit hash, and a message about the action. Find the commit you want.
To restore it:
git checkout <commit-hash>
From here, you can create a branch to preserve it:
git branch recovered-work
This method works even when the commit is unreachable from any branch. Reflog history defaults to 90 days for entries and 30 days for unreachable commits. Adjust gc.reflogExpire and gc.reflogExpireUnreachable if you need longer recall.
If you deleted a branch, git reflog show <branch> will display its movement. Combine this with git checkout to bring it back.
For complex cases, use git fsck --lost-found to detect dangling commits, then inspect and check them out. Always commit changes before attempting recovery to avoid overwriting untracked files.
Git checkout recall is not a single command, but a workflow: search the reflog, identify the commit, check it out, and rebuild what was lost. Speed matters—entries expire, and garbage collection will erase them.
Want to see git checkout recall live without setting up a repo? Run it now in minutes at hoop.dev and watch recovery happen in real time.