jesseduffield/lazygit · warning
No files staged
Error message
No files staged
What it means
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.
Source
Thrown at pkg/gui/controllers/helpers/working_tree_helper.go:231
branchName := self.refHelper.GetCheckedOutRef().Name
rgx, err := regexp.Compile(prefixPattern)
if err != nil {
return fmt.Errorf("%s: %s", self.c.Tr.CommitPrefixPatternError, err.Error())
}
if rgx.MatchString(branchName) {
initialMessage = rgx.ReplaceAllString(branchName, prefixReplace)
break
}
}
}
return self.HandleCommitPressWithMessage(initialMessage, false)
}
func (self *WorkingTreeHelper) WithEnsureCommittableFiles(handler func() error) error {
if len(self.c.Model().Files) == 0 {
return errors.New(self.c.Tr.NoFilesStagedTitle)
}
if !self.AnyStagedFiles() {
if self.c.UserConfig().Gui.SkipNoStagedFilesWarning {
self.c.LogAction(self.c.Tr.Actions.StageAllFiles)
if err := self.c.Git().WorkingTree.StageAll(false); err != nil {
return err
}
self.c.Refresh(types.RefreshOptions{
Scope: []types.RefreshableView{types.FILES},
Then: handler,
})
return nil
}
return self.promptToStageAllAndRetry(handler)
}
View on GitHub (pinned to c477a2959b)
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.
Defensive patterns
Strategy: validation
Validate before calling
// before committing:
if len(self.c.Model().Files) == 0 {
// clean tree: refresh or no-op instead of invoking the commit flow
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- You cannot commit without a commit message
- Must specify a remote if specifying a branch
- Expected renamed file
- You have no files to stash
- No changed files
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/84bf337289e416ae.
Report an issue: GitHub.