All posts

Git checkout recall: recovering lost commits and branches

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 y

Free White Paper

Git Commit Signing (GPG, SSH): The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

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:

Continue reading? Get the full guide.

Git Commit Signing (GPG, SSH): Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.
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.

Open source

Save the open-source gateway for agent data access

Hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.

Star and save the repo →More posts