nikivdev/code · error
Queued commit {} is not at HEAD (current HEAD is {}). Checko
Error message
Queued commit {} is not at HEAD (current HEAD is {}). Checkout the commit or re-run with --force. What it means
This error is thrown by the commit-approval flow when a commit previously queued (e.g. via `f commit --queue`) is no longer the HEAD of the repository at approval time. The library re-reads HEAD with `git rev-parse HEAD` and refuses to act on the queued commit unless `--force` is passed, because pushing/approving a non-HEAD commit would act on top of unrelated work. It protects against operating on a stale queue entry after the user has made newer commits.
Source
Thrown at src/commit.rs:9298
}
if unreviewed && !effective_allow_unreviewed && !force {
bail!(
"Queued commit {} does not have a clean review (missing). Re-run review, or re-run with --allow-unreviewed.",
short_sha(&entry.commit_sha)
);
}
if entry.review_timed_out && !force {
eprintln!(
"note: review timed out for {}; approving anyway (re-run `f commit-queue review {}` if you want a full review)",
short_sha(&entry.commit_sha),
short_sha(&entry.commit_sha)
);
}
let head_sha = git_capture_in(&repo_root, &["rev-parse", "HEAD"])?;
let head_sha = head_sha.trim();
if head_sha != entry.commit_sha && !force {
bail!(
"Queued commit {} is not at HEAD (current HEAD is {}). Checkout the commit or re-run with --force.",
short_sha(&entry.commit_sha),
short_sha(head_sha)
);
}
let current_branch = git_capture_in(&repo_root, &["rev-parse", "--abbrev-ref", "HEAD"])
.unwrap_or_else(|_| "unknown".to_string());
if current_branch.trim() != entry.branch && !force {
bail!(
"Queued commit was created on branch {} but current branch is {}. Checkout the branch or re-run with --force.",
entry.branch,
current_branch.trim()
);
}
ensure_safe_upstream_for_commit_queue_push(&repo_root, head_sha, force)?;
View on GitHub (pinned to a747e741ae)
Solutions
- Run `git rev-parse HEAD` and compare with the queued commit SHA to confirm the drift.
- Checkout the queued commit: `git checkout <sha>` (or the branch tip containing it), then re-run the command.
- If operating on a non-HEAD queued commit is intentional, re-run with `--force`.
- Re-queue the commit if the old SHA no longer exists (e.g. after an interactive rebase).
Example fix
// before f pr approve # fails: queued sha != HEAD // after git checkout <queued-sha> f pr approve # or: f pr approve --force
Defensive patterns
Strategy: validation
Validate before calling
let head = String::from_utf8(Command::new("git").args(["rev-parse","HEAD"]).output().unwrap().stdout).unwrap();
if head.trim() != queued_sha { eprintln!("HEAD moved; checkout {} or use --force", &queued_sha[..7]); } Try / catch
match result {
Err(e) if e.to_string().contains("not at HEAD") => eprintln!("Checkout the queued commit or re-run with --force"),
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Approve queued commits immediately after queueing them.
- Avoid rebasing/amending after queueing; re-queue if you must.
- Check `git rev-parse HEAD` against the queue before approving.
- Keep `--force` for intentional non-HEAD approvals only.
When it happens
Trigger: Running the approve/push command for a queued commit after additional commits have been made on the branch, after a rebase rewrote the queued commit's SHA, or after checking out a different commit, so `git rev-parse HEAD` no longer equals `entry.commit_sha` and `--force` was not supplied.
Common situations: Developer queues a commit, then keeps working and makes more commits before approving; a pull/rebase changed SHAs; another tool or teammate amended HEAD; the repo was switched to an older commit for debugging.
Related errors
- Queued commit was created on branch {} but current branch is
- git {} failed: {}
- {} is not inside a git repository
- not inside a git repository
- git {} failed
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/caee9ae2485abc21.
Report an issue: GitHub.