{"record":{"id":"447eb7e2cc5a8ebc","repo":"jesseduffield/lazygit","slug":"staging-or-unstaging-changes-is-not-possible-with","errorCode":null,"errorMessage":"Staging or unstaging changes is not possible with a diff context size of 0. Increase the context using '%s'.","messagePattern":"Staging or unstaging changes is not possible with a diff context size of 0\\. Increase the context using '(.+?)'\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/staging_controller.go","lineNumber":206,"sourceCode":"\t\tif state.SelectingHunkEnabledByUser() {\n\t\t\treturn self.c.Tr.SelectLineByLine\n\t\t}\n\t}\n\n\treturn self.c.Tr.ReturnToFilesPanel\n}\n\nfunc (self *StagingController) TogglePanel() error {\n\tif self.otherContext.GetState() != nil {\n\t\tself.c.Context().Push(self.otherContext, types.OnFocusOpts{})\n\t}\n\n\treturn nil\n}\n\nfunc (self *StagingController) ToggleStaged() error {\n\tif self.c.UserConfig().Git.DiffContextSize == 0 {\n\t\treturn fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToStage,\n\t\t\tself.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView)\n\t}\n\n\treturn self.applySelectionAndRefresh(self.staged)\n}\n\nfunc (self *StagingController) DiscardSelection() error {\n\tif self.c.UserConfig().Git.DiffContextSize == 0 {\n\t\treturn fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToDiscard,\n\t\t\tself.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView)\n\t}\n\n\treturn self.c.ConfirmIf(!self.staged && !self.c.UserConfig().Gui.SkipDiscardChangeWarning,\n\t\ttypes.ConfirmOpts{\n\t\t\tTitle:         self.c.Tr.DiscardChangeTitle,\n\t\t\tPrompt:        self.c.Tr.DiscardChangePrompt,\n\t\t\tHandleConfirm: func() error { return self.applySelectionAndRefresh(true) },\n\t\t})","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/staging_controller.go#L188-L224","documentation":"StagingController.ToggleStaged (pkg/gui/controllers/staging_controller.go) stage-stages or unstages the selected lines/hunks; with git.diffContextSize == 0 lazygit cannot map the selection back to hunks, so it refuses with the translated NotEnoughContextToStage message and points at the IncreaseContextInDiffView key.","triggerScenarios":"diffContextSize reduced to 0 (config `git.diffContextSize: 0` or repeated '{' presses) while in the staging panel, then pressing the stage-selection toggle (default 'space').","commonSituations":"Users preferring zero-context diffs for reading also using line-level staging; configs copied from minimal setups; after pressing '{' several times the counter in the status line is easy to miss.","solutions":["Press the increase-context key (default '}') once or more before toggling staged lines.","Or set git.diffContextSize to >= 1 in the user config.","As a workaround use whole-file staging (stage all) which does not depend on context."],"exampleFix":"# before (user config.yml)\ngit:\n  diffContextSize: 0\n\n# after\ngit:\n  diffContextSize: 3","handlingStrategy":"validation","validationCode":"if cfg.Git.DiffContextSize == 0 {\n\treturn errors.New(\"raise git.diffContextSize before line-level staging\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave diffContextSize at 0 if you stage individual lines/hunks.","Bind and remember the increase-context key; the error names it explicitly."],"tags":["config","staging","diff-context"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}