# fatal: <commit-hash> is not an ancestor of HEAD

- **ID:** `git/commit-not-ancestor-rebase`
- **Domain:** git
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Attempting to rebase onto a commit that is not reachable from the current branch's history, violating the rebase precondition that the upstream commit must be an ancestor.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| git 2.40.0 | active | — | — |
| git 2.41.1 | active | — | — |
| git 2.42.0 | active | — | — |

## Workarounds

1. **Use 'git log --oneline --graph' to inspect the commit graph and ensure the target commit is reachable, then rebase onto a correct ancestor like 'git rebase --onto <target> <old-base>'** (85% success)
   ```
   Use 'git log --oneline --graph' to inspect the commit graph and ensure the target commit is reachable, then rebase onto a correct ancestor like 'git rebase --onto <target> <old-base>'
   ```
2. **If the commit is in another branch, merge that branch first with 'git merge <other-branch>' to make the commit an ancestor, then rebase** (80% success)
   ```
   If the commit is in another branch, merge that branch first with 'git merge <other-branch>' to make the commit an ancestor, then rebase
   ```

## Dead Ends

- **** — The --onto option expects a valid upstream; using an unrelated commit still fails the ancestor check or creates a broken history. (70% fail)
- **** — Fetching updates remote refs but does not change the local branch's ancestry; the error persists unless the branch is reset or merged. (55% fail)
