{"record":{"id":"84bf337289e416ae","repo":"jesseduffield/lazygit","slug":"no-files-staged","errorCode":null,"errorMessage":"No files staged","messagePattern":"No files staged","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/helpers/working_tree_helper.go","lineNumber":231,"sourceCode":"\t\t\tbranchName := self.refHelper.GetCheckedOutRef().Name\n\t\t\trgx, err := regexp.Compile(prefixPattern)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s: %s\", self.c.Tr.CommitPrefixPatternError, err.Error())\n\t\t\t}\n\n\t\t\tif rgx.MatchString(branchName) {\n\t\t\t\tinitialMessage = rgx.ReplaceAllString(branchName, prefixReplace)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn self.HandleCommitPressWithMessage(initialMessage, false)\n}\n\nfunc (self *WorkingTreeHelper) WithEnsureCommittableFiles(handler func() error) error {\n\tif len(self.c.Model().Files) == 0 {\n\t\treturn errors.New(self.c.Tr.NoFilesStagedTitle)\n\t}\n\n\tif !self.AnyStagedFiles() {\n\t\tif self.c.UserConfig().Gui.SkipNoStagedFilesWarning {\n\t\t\tself.c.LogAction(self.c.Tr.Actions.StageAllFiles)\n\t\t\tif err := self.c.Git().WorkingTree.StageAll(false); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tself.c.Refresh(types.RefreshOptions{\n\t\t\t\tScope: []types.RefreshableView{types.FILES},\n\t\t\t\tThen:  handler,\n\t\t\t})\n\t\t\treturn nil\n\t\t}\n\n\t\treturn self.promptToStageAllAndRetry(handler)\n\t}\n","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/helpers/working_tree_helper.go#L213-L249","documentation":"Returned by WorkingTreeHelper.WithEnsureCommittableFiles when the Files model is completely empty — despite the message text ('No files staged') the actual first guard is len(Model().Files)==0, i.e. a clean working tree with nothing to commit. Only after that does it check AnyStagedFiles() and apply the SkipNoStagedFilesWarning behavior (stage everything) or warn. So the message slightly overstates: it fires when there are no changes at all, not merely none staged.","triggerScenarios":"Pressing 'c' to commit on a clean working tree (model.Files empty), e.g. right after committing or when the Files panel refresh hasn't been triggered. Any action routed through WithEnsureCommittableFiles (commit, branch-from-commit-message auto-fill) hits the same guard.","commonSituations":"Double-pressing commit after a successful commit; repo whose file watcher missed external cleanups; running the commit keybinding out of habit on a fully committed tree.","solutions":["Make or stage a change first, then commit.","Press r to refresh if you believe there are pending changes not reflected in the Files panel.","For an empty commit use the explicit allow-empty path in the commits menu rather than the normal commit flow."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before committing:\nif len(self.c.Model().Files) == 0 {\n    // clean tree: refresh or no-op instead of invoking the commit flow\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Refresh (r) before committing if files might be stale","Note the guard is 'no files at all', broader than the 'no files staged' wording","Use the explicit empty-commit menu action when an empty commit is intended"],"tags":["git","commit","clean-tree","validation","message-mismatch"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}