{"record":{"id":"caee9ae2485abc21","repo":"nikivdev/code","slug":"queued-commit-is-not-at-head-current-head-is","errorCode":null,"errorMessage":"Queued commit {} is not at HEAD (current HEAD is {}). Checkout the commit or re-run with --force.","messagePattern":"Queued commit (.+?) is not at HEAD \\(current HEAD is (.+?)\\)\\. Checkout the commit or re-run with --force\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":9298,"sourceCode":"            }\n            if unreviewed && !effective_allow_unreviewed && !force {\n                bail!(\n                    \"Queued commit {} does not have a clean review (missing). Re-run review, or re-run with --allow-unreviewed.\",\n                    short_sha(&entry.commit_sha)\n                );\n            }\n            if entry.review_timed_out && !force {\n                eprintln!(\n                    \"note: review timed out for {}; approving anyway (re-run `f commit-queue review {}` if you want a full review)\",\n                    short_sha(&entry.commit_sha),\n                    short_sha(&entry.commit_sha)\n                );\n            }\n\n            let head_sha = git_capture_in(&repo_root, &[\"rev-parse\", \"HEAD\"])?;\n            let head_sha = head_sha.trim();\n            if head_sha != entry.commit_sha && !force {\n                bail!(\n                    \"Queued commit {} is not at HEAD (current HEAD is {}). Checkout the commit or re-run with --force.\",\n                    short_sha(&entry.commit_sha),\n                    short_sha(head_sha)\n                );\n            }\n\n            let current_branch = git_capture_in(&repo_root, &[\"rev-parse\", \"--abbrev-ref\", \"HEAD\"])\n                .unwrap_or_else(|_| \"unknown\".to_string());\n            if current_branch.trim() != entry.branch && !force {\n                bail!(\n                    \"Queued commit was created on branch {} but current branch is {}. Checkout the branch or re-run with --force.\",\n                    entry.branch,\n                    current_branch.trim()\n                );\n            }\n\n            ensure_safe_upstream_for_commit_queue_push(&repo_root, head_sha, force)?;\n","sourceCodeStart":9280,"sourceCodeEnd":9316,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L9280-L9316","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nf pr approve   # fails: queued sha != HEAD\n// after\ngit checkout <queued-sha>\nf pr approve   # or: f pr approve --force","handlingStrategy":"validation","validationCode":"let head = String::from_utf8(Command::new(\"git\").args([\"rev-parse\",\"HEAD\"]).output().unwrap().stdout).unwrap();\nif head.trim() != queued_sha { eprintln!(\"HEAD moved; checkout {} or use --force\", &queued_sha[..7]); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"not at HEAD\") => eprintln!(\"Checkout the queued commit or re-run with --force\"),\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["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."],"tags":["git","cli","state-mismatch"],"backgroundTag":"commit-not-at-head","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}