# 致命：您当前不在一个分支上。请先使用 'git rebase --onto' 或 'git checkout'。

- **ID:** `git/rebase-detached-head`
- **领域:** git
- **类别:** user_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

用户在分离 HEAD 状态下尝试运行 git rebase，因为没有任何分支可以更新，所以不允许这样做。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| git 2.33.0 | active | — | — |
| git 2.38.0 | active | — | — |
| git 2.45.0 | active | — | — |

## 解决方案

1. ```
   Create a branch from the current detached HEAD: 'git checkout -b temp-branch', then run rebase.
   ```
2. ```
   Use 'git rebase --onto <target> <upstream>' to rebase without needing a branch.
   ```

## 无效尝试

- **** — Running 'git rebase <branch>' without checking out a branch first will still fail. (90% 失败率)
- **** — Using 'git rebase --continue' after a failed rebase in detached state will not resolve the issue. (80% 失败率)
