{"record":{"id":"87435c8c71003f19","repo":"jesseduffield/lazygit","slug":"expected-exactly-one-merge-commit-with-hash-s","errorCode":null,"errorMessage":"Expected exactly one merge commit with hash %s","messagePattern":"Expected exactly one merge commit with hash (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/utils/rebase_todo.go","lineNumber":328,"sourceCode":"\ttodos, err := ReadRebaseTodoFile(fileName, commentChar)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewTodos, err := dropMergeCommit(todos, hash)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn WriteRebaseTodoFile(fileName, newTodos, commentChar)\n}\n\nfunc dropMergeCommit(todos []todo.Todo, hash string) ([]todo.Todo, error) {\n\tisMerge := func(t todo.Todo) bool {\n\t\treturn t.Command == todo.Merge && t.Flag == \"-C\" && equalHash(t.Commit, hash)\n\t}\n\tif lo.CountBy(todos, isMerge) != 1 {\n\t\treturn nil, fmt.Errorf(\"Expected exactly one merge commit with hash %s\", hash)\n\t}\n\n\t_, idx, _ := lo.FindIndexOf(todos, isMerge)\n\treturn slices.Delete(todos, idx, idx+1), nil\n}\n","sourceCodeStart":310,"sourceCodeEnd":334,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/utils/rebase_todo.go#L310-L334","documentation":"Returned by dropMergeCommit when dropping a merge commit during a rebase: it looks for exactly one todo with command 'merge', flag '-C', and the given hash. If none or several match (typically zero, because the merge is recorded differently or already handled), the drop is refused since deleting the wrong line would corrupt the plan.","triggerScenarios":"Dropping a merge commit from lazygit's commits view during an interactive rebase where the todo file lacks a 'merge -C <hash>' line for it (older git writing 'merge' differently, the merge already applied, or an externally edited todo).","commonSituations":"Rebases created by older git versions or other tools that don't emit 'merge -C'; attempting to drop a merge whose todo entry was already consumed; hash format mismatches (full vs abbreviated) in the todo file.","solutions":["Open .git-rebase-todo and confirm a 'merge -C <hash>' line exists with the exact hash shown; edit manually if the encoding differs","If the merge was already applied, refresh/restart the rebase view before dropping","Upgrade git so rebase todos use the merge -C form lazygit expects"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# verify the exact merge line exists before dropping\ngrep -cE \"^merge -C ${FULL_HASH}\" .git/rebase-merge/git-rebase-todo  # want exactly 1","typeGuard":null,"tryCatchPattern":"Catch, show the expected 'merge -C <hash>' form to the user, and offer to open the todo file for manual editing instead of retrying blind.","preventionTips":["Use a git version whose rebase todos record merges as 'merge -C <hash>'","Confirm the merge is still pending in the todo before dropping it from lazygit"],"tags":["lazygit","rebase","merge-commit","git-rebase-todo"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}