{"record":{"id":"f98136818aeb6687","repo":"jesseduffield/lazygit","slug":"you-have-no-tracked-staged-files-to-stash","errorCode":null,"errorMessage":"You have no tracked/staged files to stash","messagePattern":"You have no tracked/staged files to stash","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/gui/controllers/files_controller.go","lineNumber":1307,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t\t// if there are no staged files it behaves the same as Stash.Save\n\t\t\t\t\treturn self.handleStashSave(self.c.Git().Stash.StashAndKeepIndex, self.c.Tr.Actions.StashAllChangesKeepIndex)\n\t\t\t\t},\n\t\t\t\tKeys: menuKey('i'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tLabel: self.c.Tr.StashIncludeUntrackedChanges,\n\t\t\t\tOnPress: func() error {\n\t\t\t\t\treturn self.handleStashSave(self.c.Git().Stash.StashIncludeUntrackedChanges, self.c.Tr.Actions.StashIncludeUntrackedChanges)\n\t\t\t\t},\n\t\t\t\tKeys: menuKey('U'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tLabel: self.c.Tr.StashStagedChanges,\n\t\t\t\tOnPress: func() error {\n\t\t\t\t\t// there must be something in staging otherwise the current implementation mucks the stash up\n\t\t\t\t\tif !self.c.Helpers().WorkingTree.AnyStagedFilesExceptSubmodules() {\n\t\t\t\t\t\treturn errors.New(self.c.Tr.NoTrackedStagedFilesStash)\n\t\t\t\t\t}\n\t\t\t\t\treturn self.handleStashSave(self.c.Git().Stash.SaveStagedChanges, self.c.Tr.Actions.StashStagedChanges)\n\t\t\t\t},\n\t\t\t\tKeys: menuKey('s'),\n\t\t\t},\n\t\t\t{\n\t\t\t\tLabel: self.c.Tr.StashUnstagedChanges,\n\t\t\t\tOnPress: func() error {\n\t\t\t\t\tif !self.c.Helpers().WorkingTree.IsWorkingTreeDirtyExceptSubmodules() {\n\t\t\t\t\t\treturn errors.New(self.c.Tr.NoFilesToStash)\n\t\t\t\t\t}\n\t\t\t\t\tif self.c.Helpers().WorkingTree.AnyStagedFilesExceptSubmodules() {\n\t\t\t\t\t\treturn self.handleStashSave(self.c.Git().Stash.StashUnstagedChanges, self.c.Tr.Actions.StashUnstagedChanges)\n\t\t\t\t\t}\n\t\t\t\t\t// ordinary stash\n\t\t\t\t\treturn self.handleStashSave(self.c.Git().Stash.Push, self.c.Tr.Actions.StashUnstagedChanges)\n\t\t\t\t},\n\t\t\t\tKeys: menuKey('u'),","sourceCodeStart":1289,"sourceCodeEnd":1325,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/files_controller.go#L1289-L1325","documentation":"Thrown from the stash menu's 'stash staged changes' item when AnyStagedFilesExceptSubmodules() is false. This option maps to 'git stash --staged' (SaveStagedChanges); the source comment notes that without something in the index the current implementation 'mucks the stash up', so lazygit requires at least one staged file before allowing it.","triggerScenarios":"Selecting 'stash staged changes' (menu key 's') when nothing is staged — all changes are unstaged or the tree is clean.","commonSituations":"Users who stage nothing but expect the option to stash their unstaged work, or who press it right after stashing once so the index is empty.","solutions":["Stage at least one file first ('space' in the files panel), then choose stash staged changes","If you meant to stash everything, use 'stash all changes' instead"],"exampleFix":"# before: nothing staged, stash-staged errors\n# after\ngit add path/to/file\n# then select 'stash staged changes' (git stash --staged)","handlingStrategy":"validation","validationCode":"// Require staged files for the --staged variant:\nif !workingTree.AnyStagedFilesExceptSubmodules() {\n    return errors.New(\"stage at least one file before stashing staged changes\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the index is non-empty before 'git stash --staged'","Offer to fall back to 'stash all changes' when nothing is staged","Show staged-count in the stash menu so the precondition is visible"],"tags":["git","stash","staged-changes","precondition"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}