How to fix fatal: bad revision 'HEAD@{10}' in Git

GitINTERMEDIATEMEDIUMUpdated Dec 6, 2025ยท 148 views

This error occurs when Git cannot find the reflog entry you referenced. Reflog entries expire after 90 days by default, or the reference may have been garbage collected.

Quick fix

Fixes fatal: bad revision 'HEAD@{10}'

git reflog
  1. Check available reflog entries
  2. View reflog with timestamps
  3. Use git fsck to find dangling commits
  4. Check branch-specific reflogs
git โ€” error
git reflog
fatal: bad revision 'HEAD@{10}'

What this error means

The `HEAD@{n}` syntax refers to the nth previous position of HEAD as recorded in Git's reflog. When you see "fatal: bad revision 'HEAD@{10}'", it means Git cannot find that specific reflog entry. The reflog (reference log) is a local record of where your HEAD and branch tips have pointed over time. It's like an undo history for your repository. However, reflog entries are not permanent - by default, Git expires entries older than 90 days for reachable commits and 30 days for unreachable commits. This error commonly appears when trying to recover old commits using `git reset`, `git checkout`, or `git show` with a reflog reference that no longer exists. Unlike regular Git history, the reflog is purely local and is not shared through pushes, fetches, or clones.

Typical symptoms

  • Running `git reset --hard HEAD@{n}` fails with 'bad revision' error
  • Attempting to view old commits with `git show HEAD@{n}` returns an error
  • Commands like `git diff HEAD@{n}` or `git log HEAD@{n}` fail
  • The reflog entry you're trying to access is older than expected
  • Recovery attempts after running `git gc` fail for older references

Common causes

  1. The reflog entry has expired (default: 90 days for reachable, 30 days for unreachable commits)
  2. Git garbage collection (`git gc`) has cleaned up old reflog entries
  3. The repository was cloned or fetched (reflogs are local-only and not transferred)
  4. The reflog was manually expired using `git reflog expire`
  5. The index number exceeds the total number of reflog entries available
  6. The `.git/logs/HEAD` file was corrupted or deleted

How to fix "fatal: bad revision 'HEAD@{10}'"

1Check available reflog entries

First, see what reflog entries actually exist:

bash
git reflog

This shows all available HEAD positions. If your desired entry isn't listed, it has likely expired. Note the highest index number available - you cannot reference beyond this.

2View reflog with timestamps

Check when entries expire to understand the timeline:

bash
git reflog --date=relative

Or with absolute dates:

bash
git reflog --date=iso

Entries older than 90 days (reachable) or 30 days (unreachable) may be expired.

3Use git fsck to find dangling commits

If reflog entries are gone, use git fsck to find orphaned commits:

bash
git fsck --lost-found

This lists dangling commits, blobs, and trees. Look through the output for commits:

bash
git show <commit-hash>

Once you find the commit you need, recover it:

bash
git checkout -b recovered-branch <commit-hash>
4Check branch-specific reflogs

Each branch has its own reflog. Try accessing the branch reflog instead:

bash
git reflog show main
git reflog show <branch-name>

You can reference these as main@{n} instead of HEAD@{n}.

5Recover using a known commit hash

If you know the commit hash from CI logs, IDE history, or elsewhere:

bash
# View the commit
git show <commit-hash>

# Create a branch from it
git checkout -b recovered-branch <commit-hash>

# Or reset your current branch to it
git reset --hard <commit-hash>
6Extend reflog retention to prevent future issues

Increase reflog expiration times to keep entries longer:

bash
# Keep reachable reflog entries for 1 year
git config --global gc.reflogExpire "365 days"

# Keep unreachable reflog entries for 180 days
git config --global gc.reflogExpireUnreachable "180 days"

To never expire reflog entries (use with caution - consumes disk space):

bash
git config --global gc.reflogExpire never
git config --global gc.reflogExpireUnreachable never

Advanced notes

## Reflog Expiration Configuration

Git has two configuration settings controlling reflog expiration:

- `gc.reflogExpire`: Time to keep entries for commits reachable from current branch tips (default: 90 days)
- `gc.reflogExpireUnreachable`: Time to keep entries for unreachable commits (default: 30 days)

You can set pattern-specific expiration with gc.<pattern>.reflogExpire, for example:

bash
# Keep stash reflog forever
git config gc.refs/stash.reflogExpire never

## When Garbage Collection Runs

Reflog entries are pruned when git gc runs, which happens:
- Automatically via git gc --auto (triggered by various Git operations)
- Manually when you run git gc
- During git repack operations

To check current settings:

bash
git config --get gc.reflogExpire
git config --get gc.reflogExpireUnreachable

## Manual Reflog File Access

The reflog is stored in plain text at .git/logs/HEAD and .git/logs/refs/heads/<branch>. In emergencies, you can read these files directly:

bash
cat .git/logs/HEAD

## Time-Based Reflog Syntax

Instead of numeric indices, you can use time-based references:

bash
git show HEAD@{yesterday}
git show HEAD@{2.weeks.ago}
git show main@{2024-01-15}

These still depend on reflog entries existing for that timeframe.

Frequently asked questions

What does "fatal: bad revision 'HEAD@{10}'" mean?
The HEAD@{n} syntax refers to the nth previous position of HEAD as recorded in Git's reflog. When you see "fatal: bad revision 'HEAD@{10}'", it means Git cannot find that specific reflog entry. The reflog (reference log) is a local record of where your HEAD and branch tips have pointed over time.
How do I fix "fatal: bad revision 'HEAD@{10}'"?
This error occurs when Git cannot find the reflog entry you referenced. Reflog entries expire after 90 days by default, or the reference may have been garbage collected.
What causes "fatal: bad revision 'HEAD@{10}'"?
The reflog entry has expired (default: 90 days for reachable, 30 days for unreachable commits) Git garbage collection (git gc) has cleaned up old reflog entries The repository was cloned or fetched (reflogs are local-only and not transferred)
Is the "fatal: bad revision 'HEAD@{10}'" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading