jesseduffield/lazygit · error

You are midway through another rebase operation. Please abor

Error message

You are midway through another rebase operation. Please abort to start again

What it means

In the amend-source path of MovePatchIntoCommit (patch.go:192), after amending HEAD and computing the diff patch, lazygit checks rebase.onSuccessfulContinue; if a callback is already registered it means another patch-driven interactive rebase is in flight and registering a second one would clobber the first. The error tells the user to abort the pending rebase first.

Source

Thrown at pkg/commands/git_commands/patch.go:192

	// apply each patch in reverse
	if err := self.ApplyCustomPatch(true, true); err != nil {
		_ = self.rebase.AbortRebase()
		return err
	}

	// amend the source commit
	if err := self.commit.AmendHead(); err != nil {
		return err
	}

	patch, err := self.diffHeadAgainstCommit(commits[sourceCommitIdx])
	if err != nil {
		_ = self.rebase.AbortRebase()
		return err
	}

	if self.rebase.onSuccessfulContinue != nil {
		return errors.New("You are midway through another rebase operation. Please abort to start again")
	}

	self.rebase.onSuccessfulContinue = func() error {
		// now we should be up to the destination, so let's apply forward these patches to that.
		// ideally we would ensure we're on the right commit but I'm not sure if that check is necessary
		if err := self.ApplyPatch(patch, ApplyPatchOpts{Index: true, ThreeWay: true}); err != nil {
			// Don't abort the rebase here; this might cause conflicts, so give
			// the user a chance to resolve them
			return err
		}

		// amend the destination commit
		if err := self.commit.AmendHead(); err != nil {
			return err
		}

		self.rebase.onSuccessfulContinue = func() error {
			self.PatchBuilder.Reset()

View on GitHub (pinned to c477a2959b)

Solutions

  1. Abort the in-progress rebase (lazygit's abort/`git rebase --abort`) and retry the operation from a clean state
  2. Finish or continue the pending rebase before starting a new patch operation
  3. Confirm working tree state is clean (`git status`) before history-rewriting actions

Example fix

# before
# mid-rebase, start another move-patch -> error
$ git rebase --abort  # then retry

# after
$ lazygit  # 'm' to move patch now succeeds on clean state
Defensive patterns

Strategy: validation

Validate before calling

if gitCommands.Status.WorkingTreeState().Rebasing {
    return errors.New("finish or abort the current rebase before moving patches")
}

Try / catch

On this message, prompt 'abort current rebase?' — the only sane recovery is aborting the suspended operation; retrying the same call without aborting always fails.

Prevention

When it happens

Trigger: Invoking a second patch operation (move/copy patch into commit) while a prior one is suspended mid-rebase awaiting continue; concurrency between two actions both using the onSuccessfulContinue hook.

Common situations: User starts moving a patch, the rebase stops on a conflict, and instead of resolving/continuing they start another move-patch action.

Related errors


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