jesseduffield/lazygit · error

Can't redo while rebasing

Error message

Can't redo while rebasing

What it means

Returned by UndoController.reflogRedo (shift-Z redo) under the same condition as undo: WorkingTreeState().Any() is true, meaning a rebase/merge/cherry-pick is in progress. Redo replays reflog actions forward and cannot be applied safely on top of an unfinished working-tree operation.

Source

Thrown at pkg/gui/controllers/undo_controller.go:145

				},
			})
			return true, nil

		case CURRENT_REBASE:
			// do nothing
		}

		self.c.Log.Error("didn't match on the user action when trying to undo")
		return true, nil
	})
}

func (self *UndoController) reflogRedo() error {
	redoEnvVars := []string{"GIT_REFLOG_ACTION=[lazygit redo]"}
	redoingStatus := self.c.Tr.RedoingStatus

	if self.c.Git().Status.WorkingTreeState().Any() {
		return errors.New(self.c.Tr.CantRedoWhileRebasing)
	}

	return self.parseReflogForActions(func(counter int, action reflogAction) (bool, error) {
		// if we're redoing and the counter is zero, we just return
		if counter == 0 {
			return true, nil
		} else if counter > 1 {
			return false, nil
		}

		switch action.kind {
		case COMMIT, REBASE:
			self.c.Confirm(types.ConfirmOpts{
				Title:  self.c.Tr.Actions.Redo,
				Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, utils.ShortHash(action.to)),
				HandleConfirm: func() error {
					self.c.LogAction(self.c.Tr.Actions.Redo)
					return self.hardResetWithAutoStash(action.to, hardResetOptions{

View on GitHub (pinned to c477a2959b)

Solutions

  1. Complete or abort the in-progress operation (e.g. 'git rebase --abort' or resolve conflicts), then redo.
  2. Verify with 'git status' that no operation is listed as in progress before retrying.
  3. Clean up stale state directories only after confirming no git process is running.

Example fix

# before
$ # mid-merge, pressed redo (Z) -> Can't redo while rebasing

# after
$ git merge --abort
# then press Z in lazygit
Defensive patterns

Strategy: validation

Validate before calling

if self.c.Git().Status.WorkingTreeState().Any() {
    // block redo until the working tree state is clean
}

Prevention

When it happens

Trigger: Pressing redo while a rebase, merge, or cherry-pick is active in the repository.

Common situations: User undid a commit, started a rebase, then tries to redo mid-rebase; leftover state from a crashed git operation.

Related errors


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