{"record":{"id":"28487c299f9b9796","repo":"jesseduffield/lazygit","slug":"multiple-base-commits-found-try-staging-fewer-ch","errorCode":null,"errorMessage":"Multiple base commits found. (Try staging fewer changes at once)\n\n%s","messagePattern":"Multiple base commits found\\. \\(Try staging fewer changes at once\\)\n\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/helpers/fixup_helper.go","lineNumber":126,"sourceCode":"\t\t// error. It isn't worth doing a detailed report of which commits we\n\t\t// found.\n\t\treturn errors.New(self.c.Tr.BaseCommitIsAlreadyOnMainBranch)\n\t}\n\n\tfoundCommits := getCommitsForHashes(commits, hashGroups[NOT_MERGED])\n\t// If there are multiple commits that could be the base commit, remove all\n\t// those that are fixups for the last one.\n\tfoundCommits = removeFixupCommits(foundCommits)\n\n\tif len(foundCommits) > 1 {\n\t\t// If there are still multiple commits that could be the base commit, list\n\t\t// them in the error message. But only the candidates from the current\n\t\t// branch, not including any that are already merged.\n\t\tsubjects := getHashesAndSubjects(foundCommits)\n\t\tmessage := lo.Ternary(hasStagedChanges,\n\t\t\tself.c.Tr.MultipleBaseCommitsFoundStaged,\n\t\t\tself.c.Tr.MultipleBaseCommitsFoundUnstaged)\n\t\treturn fmt.Errorf(\"%s\\n\\n%s\", message, subjects)\n\t}\n\n\t// Now we know that foundCommits has exactly one commit, so find its index\n\t_, index, _ := self.findCommit(commits, foundCommits[0].Hash())\n\n\treturn self.c.ConfirmIf(warnAboutAddedLines, types.ConfirmOpts{\n\t\tTitle:  self.c.Tr.FindBaseCommitForFixup,\n\t\tPrompt: self.c.Tr.HunksWithOnlyAddedLinesWarning,\n\t\tHandleConfirm: func() error {\n\t\t\tif !hasStagedChanges {\n\t\t\t\tif err := self.c.Git().WorkingTree.StageAll(true); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tself.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}})\n\t\t\t}\n\n\t\t\tself.c.Contexts().LocalCommits.SetSelection(index)\n\t\t\tself.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/helpers/fixup_helper.go#L108-L144","documentation":"FixupHelper (pkg/gui/controllers/helpers/fixup_helper.go) implements 'find base commit for fixup': it maps changed lines back to candidate commits via blame, removes fixup commits for the last candidate, and if more than one candidate remains it fails with MultipleBaseCommitsFoundStaged/Unstaged plus the list of candidate hashes and subjects. Ambiguity, not corruption: the staged/unstaged changes span code owned by several different commits.","triggerScenarios":"Pressing the find-base-commit-for-fixup key (default 'F') on the commits view when the working-tree/staged changes touch lines last modified by two or more distinct non-fixup commits — e.g. editing two functions introduced by different commits in one file, then staging both hunks together.","commonSituations":"Bulk edits before remembering to fixup; staging all (a) instead of selecting hunks; mixed refactors that overlap many commits; partially reverting a change whose lines have multiple owners.","solutions":["Stage only the changes belonging to one commit: unstage all, then stage individual hunks/lines in the staging panel and re-run fixup.","Pick the intended target from the hash/subject list in the error and create a manual fixup/squash via the commit menu instead of the automatic finder.","Commit the unrelated part first, then run find-base-commit again for the remainder."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The helper surfaces ambiguity as an error; handle it by narrowing the selection:\nif err := findBaseCommitForFixup(); err != nil {\n\tif strings.Contains(err.Error(), \"Multiple base commits found\") {\n\t\t// prompt user to stage fewer hunks, or pick a target from the listed candidates\n\t}\n}","preventionTips":["Stage hunk-by-hunk for one logical change before invoking find-base-commit-for-fixup.","Avoid mixing edits from multiple features in a single staging pass.","Commit noisy mechanical changes (formatting) separately so blame maps cleanly."],"tags":["git","fixup","blame","staging"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}