{"record":{"id":"d16035b64ae3e787","repo":"jesseduffield/lazygit","slug":"can-t-undo-while-rebasing","errorCode":null,"errorMessage":"Can't undo while rebasing","messagePattern":"Can't undo while rebasing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gui/controllers/undo_controller.go","lineNumber":81,"sourceCode":"\t\t\tHandler:     self.reflogRedo,\n\t\t\tDescription: self.c.Tr.RedoReflog,\n\t\t\tTooltip:     self.c.Tr.RedoTooltip,\n\t\t},\n\t}\n\n\treturn bindings\n}\n\nfunc (self *UndoController) Context() types.Context {\n\treturn nil\n}\n\nfunc (self *UndoController) reflogUndo() error {\n\tundoEnvVars := []string{\"GIT_REFLOG_ACTION=[lazygit undo]\"}\n\tundoingStatus := self.c.Tr.UndoingStatus\n\n\tif self.c.Git().Status.WorkingTreeState().Any() {\n\t\treturn errors.New(self.c.Tr.CantUndoWhileRebasing)\n\t}\n\n\treturn self.parseReflogForActions(func(counter int, action reflogAction) (bool, error) {\n\t\tif counter != 0 {\n\t\t\treturn false, nil\n\t\t}\n\n\t\tswitch action.kind {\n\t\tcase COMMIT:\n\t\t\tself.c.Confirm(types.ConfirmOpts{\n\t\t\t\tTitle:  self.c.Tr.Actions.Undo,\n\t\t\t\tPrompt: fmt.Sprintf(self.c.Tr.SoftResetPrompt, utils.ShortHash(action.from)),\n\t\t\t\tHandleConfirm: func() error {\n\t\t\t\t\tself.c.LogAction(self.c.Tr.Actions.Undo)\n\t\t\t\t\treturn self.c.WithWaitingStatus(undoingStatus, func(gocui.Task) error {\n\t\t\t\t\t\treturn self.c.Helpers().Refs.ResetToRef(action.from, \"soft\", undoEnvVars)\n\t\t\t\t\t})\n\t\t\t\t},","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/undo_controller.go#L63-L99","documentation":"Returned by UndoController.reflogUndo when Git().Status.WorkingTreeState().Any() is true — i.e. a rebase, merge, or cherry-pick is in progress. Undoing reflog actions rewrites refs and resets state, which would collide with the in-progress operation, so undo (press 'z') is refused until the working tree state is clean.","triggerScenarios":"Pressing undo while .git has an active rebase-merge/merge/cherry-pick/revert state (WorkingTreeState().Any() == true).","commonSituations":"User hits a conflict mid-rebase and instinctively presses undo; aborting an operation was intended but undo was pressed instead; a background operation left state files behind.","solutions":["Resolve or abort the in-progress rebase/merge (abort is usually 'a' in the status/commits panel), then undo.","If a previous operation crashed and left stale state, run 'git rebase --abort' / 'git merge --abort' / delete stale state files after verifying with 'git status'.","After the working tree state is clean, retry undo."],"exampleFix":"# before\n$ # mid-rebase, pressed undo (z) -> Can't undo while rebasing\n\n# after\n$ git rebase --abort\n# then press z in lazygit","handlingStrategy":"validation","validationCode":"if self.c.Git().Status.WorkingTreeState().Any() {\n    // prompt to abort/continue the in-progress operation before undo\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check WorkingTreeState().Any() before enabling the undo keybinding.","Resolve or abort in-progress rebases/merges before reaching for undo.","After a crashed git operation, clean stale state with 'git status' verification before undoing."],"tags":["git","undo","reflog","rebase-state"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}