{"record":{"id":"24a02418637bffc1","repo":"jesseduffield/lazygit","slug":"the-base-commit-for-this-change-is-already-on-the","errorCode":null,"errorMessage":"The base commit for this change is already on the main branch","messagePattern":"The base commit for this change is already on the main branch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/helpers/fixup_helper.go","lineNumber":110,"sourceCode":"\t\t}\n\t\treturn lo.Ternary(notFoundMeansMerged, MERGED, CANNOT_TELL)\n\t})\n\n\tif len(hashGroups[CANNOT_TELL]) > 0 {\n\t\t// If we have any commits that we can't tell if they're merged, just\n\t\t// show the generic \"not in current view\" error. This can only happen if\n\t\t// a feature branch has more than 300 commits, or there is no main\n\t\t// branch. Both are so unlikely that we don't bother returning a more\n\t\t// detailed error message (e.g. we could say something about the commits\n\t\t// that *are* in the current branch, but it's not worth it).\n\t\treturn errors.New(self.c.Tr.BaseCommitIsNotInCurrentView)\n\t}\n\n\tif len(hashGroups[NOT_MERGED]) == 0 {\n\t\t// If all the commits are merged, show the \"already on main branch\"\n\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","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/helpers/fixup_helper.go#L92-L128","documentation":"Returned when every candidate base commit for the selected change is classified as MERGED, meaning the lines were last touched by commits already contained in the main branch. A fixup commit would never be applied by 'git rebase --autosquash' onto main history in this branch's future, so lazygit refuses rather than creating an orphan fixup.","triggerScenarios":"Pressing shift-F on modified lines whose blame points at commits that the model marks StatusMerged (or that fall past a merged last-known commit while notFoundMeansMerged holds) — e.g. editing a file directly on main, or on a branch created after those commits merged.","commonSituations":"Committing directly on top of main/master and trying fixup anyway; touching vendor or generated files whose lines were all introduced by long-merged commits; forgetting to branch before editing.","solutions":["Create the commit as a regular commit instead of a fixup — the base is already in main.","If you meant to amend a recent local commit on this branch, use the amend option (a) instead.","If you expected the base to be a branch-local commit, verify which commit git blame attributes the lines to."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before fixup, check the touched lines' base:\n// git blame -L<n>,<n> HEAD -- <file> -> if base is on main, commit normally instead","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Branch before editing when you intend fixups","Use amend (a) for the branch's own last commit rather than fixup"],"tags":["git","fixup","merged-commits","main-branch"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}