jesseduffield/lazygit · warning

The base commit for this change is already on the main branc

Error message

The base commit for this change is already on the main branch

What it means

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.

Source

Thrown at pkg/gui/controllers/helpers/fixup_helper.go:110

		}
		return lo.Ternary(notFoundMeansMerged, MERGED, CANNOT_TELL)
	})

	if len(hashGroups[CANNOT_TELL]) > 0 {
		// If we have any commits that we can't tell if they're merged, just
		// show the generic "not in current view" error. This can only happen if
		// a feature branch has more than 300 commits, or there is no main
		// branch. Both are so unlikely that we don't bother returning a more
		// detailed error message (e.g. we could say something about the commits
		// that *are* in the current branch, but it's not worth it).
		return errors.New(self.c.Tr.BaseCommitIsNotInCurrentView)
	}

	if len(hashGroups[NOT_MERGED]) == 0 {
		// If all the commits are merged, show the "already on main branch"
		// error. It isn't worth doing a detailed report of which commits we
		// found.
		return errors.New(self.c.Tr.BaseCommitIsAlreadyOnMainBranch)
	}

	foundCommits := getCommitsForHashes(commits, hashGroups[NOT_MERGED])
	// If there are multiple commits that could be the base commit, remove all
	// those that are fixups for the last one.
	foundCommits = removeFixupCommits(foundCommits)

	if len(foundCommits) > 1 {
		// If there are still multiple commits that could be the base commit, list
		// them in the error message. But only the candidates from the current
		// branch, not including any that are already merged.
		subjects := getHashesAndSubjects(foundCommits)
		message := lo.Ternary(hasStagedChanges,
			self.c.Tr.MultipleBaseCommitsFoundStaged,
			self.c.Tr.MultipleBaseCommitsFoundUnstaged)
		return fmt.Errorf("%s\n\n%s", message, subjects)
	}

View on GitHub (pinned to c477a2959b)

Solutions

  1. Create the commit as a regular commit instead of a fixup — the base is already in main.
  2. If you meant to amend a recent local commit on this branch, use the amend option (a) instead.
  3. If you expected the base to be a branch-local commit, verify which commit git blame attributes the lines to.
Defensive patterns

Strategy: validation

Validate before calling

// before fixup, check the touched lines' base:
// git blame -L<n>,<n> HEAD -- <file> -> if base is on main, commit normally instead

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/24a02418637bffc1. Report an issue: GitHub.