{"record":{"id":"4a128aeb294d34b2","repo":"jesseduffield/lazygit","slug":"can-t-redo-while-rebasing","errorCode":null,"errorMessage":"Can't redo while rebasing","messagePattern":"Can't redo while rebasing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gui/controllers/undo_controller.go","lineNumber":145,"sourceCode":"\t\t\t\t},\n\t\t\t})\n\t\t\treturn true, nil\n\n\t\tcase CURRENT_REBASE:\n\t\t\t// do nothing\n\t\t}\n\n\t\tself.c.Log.Error(\"didn't match on the user action when trying to undo\")\n\t\treturn true, nil\n\t})\n}\n\nfunc (self *UndoController) reflogRedo() error {\n\tredoEnvVars := []string{\"GIT_REFLOG_ACTION=[lazygit redo]\"}\n\tredoingStatus := self.c.Tr.RedoingStatus\n\n\tif self.c.Git().Status.WorkingTreeState().Any() {\n\t\treturn errors.New(self.c.Tr.CantRedoWhileRebasing)\n\t}\n\n\treturn self.parseReflogForActions(func(counter int, action reflogAction) (bool, error) {\n\t\t// if we're redoing and the counter is zero, we just return\n\t\tif counter == 0 {\n\t\t\treturn true, nil\n\t\t} else if counter > 1 {\n\t\t\treturn false, nil\n\t\t}\n\n\t\tswitch action.kind {\n\t\tcase COMMIT, REBASE:\n\t\t\tself.c.Confirm(types.ConfirmOpts{\n\t\t\t\tTitle:  self.c.Tr.Actions.Redo,\n\t\t\t\tPrompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, utils.ShortHash(action.to)),\n\t\t\t\tHandleConfirm: func() error {\n\t\t\t\t\tself.c.LogAction(self.c.Tr.Actions.Redo)\n\t\t\t\t\treturn self.hardResetWithAutoStash(action.to, hardResetOptions{","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/undo_controller.go#L127-L163","documentation":"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.","triggerScenarios":"Pressing redo while a rebase, merge, or cherry-pick is active in the repository.","commonSituations":"User undid a commit, started a rebase, then tries to redo mid-rebase; leftover state from a crashed git operation.","solutions":["Complete or abort the in-progress operation (e.g. 'git rebase --abort' or resolve conflicts), then redo.","Verify with 'git status' that no operation is listed as in progress before retrying.","Clean up stale state directories only after confirming no git process is running."],"exampleFix":"# before\n$ # mid-merge, pressed redo (Z) -> Can't redo while rebasing\n\n# after\n$ git merge --abort\n# then press Z in lazygit","handlingStrategy":"validation","validationCode":"if self.c.Git().Status.WorkingTreeState().Any() {\n    // block redo until the working tree state is clean\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Gate redo with the same WorkingTreeState check as undo.","Finish or abort the current rebase/merge before redoing reflog actions.","Verify with 'git status' that no operation is in progress when the guard trips unexpectedly."],"tags":["git","redo","reflog","rebase-state"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}