{"record":{"id":"997a6660e17f4aff","repo":"jesseduffield/lazygit","slug":"you-are-midway-through-another-rebase-operation-p","errorCode":null,"errorMessage":"You are midway through another rebase operation. Please abort to start again","messagePattern":"You are midway through another rebase operation\\. Please abort to start again","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/git_commands/patch.go","lineNumber":192,"sourceCode":"\t// apply each patch in reverse\n\tif err := self.ApplyCustomPatch(true, true); err != nil {\n\t\t_ = self.rebase.AbortRebase()\n\t\treturn err\n\t}\n\n\t// amend the source commit\n\tif err := self.commit.AmendHead(); err != nil {\n\t\treturn err\n\t}\n\n\tpatch, err := self.diffHeadAgainstCommit(commits[sourceCommitIdx])\n\tif err != nil {\n\t\t_ = self.rebase.AbortRebase()\n\t\treturn err\n\t}\n\n\tif self.rebase.onSuccessfulContinue != nil {\n\t\treturn errors.New(\"You are midway through another rebase operation. Please abort to start again\")\n\t}\n\n\tself.rebase.onSuccessfulContinue = func() error {\n\t\t// now we should be up to the destination, so let's apply forward these patches to that.\n\t\t// ideally we would ensure we're on the right commit but I'm not sure if that check is necessary\n\t\tif err := self.ApplyPatch(patch, ApplyPatchOpts{Index: true, ThreeWay: true}); err != nil {\n\t\t\t// Don't abort the rebase here; this might cause conflicts, so give\n\t\t\t// the user a chance to resolve them\n\t\t\treturn err\n\t\t}\n\n\t\t// amend the destination commit\n\t\tif err := self.commit.AmendHead(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tself.rebase.onSuccessfulContinue = func() error {\n\t\t\tself.PatchBuilder.Reset()","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/commands/git_commands/patch.go#L174-L210","documentation":"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.","triggerScenarios":"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.","commonSituations":"User starts moving a patch, the rebase stops on a conflict, and instead of resolving/continuing they start another move-patch action.","solutions":["Abort the in-progress rebase (lazygit's abort/`git rebase --abort`) and retry the operation from a clean state","Finish or continue the pending rebase before starting a new patch operation","Confirm working tree state is clean (`git status`) before history-rewriting actions"],"exampleFix":"# before\n# mid-rebase, start another move-patch -> error\n$ git rebase --abort  # then retry\n\n# after\n$ lazygit  # 'm' to move patch now succeeds on clean state","handlingStrategy":"validation","validationCode":"if gitCommands.Status.WorkingTreeState().Rebasing {\n    return errors.New(\"finish or abort the current rebase before moving patches\")\n}","typeGuard":null,"tryCatchPattern":"On this message, prompt 'abort current rebase?' — the only sane recovery is aborting the suspended operation; retrying the same call without aborting always fails.","preventionTips":["Complete or abort one patch operation before starting the next","Watch lazygit's rebase-in-progress banner before history actions","Avoid queuing multiple fixup/move operations during conflicts"],"tags":["rebase","concurrency","state-conflict","interactive"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}