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

  1. Make or stage a change first, then commit.
  2. Press r to refresh if you believe there are pending changes not reflected in the Files panel.
  3. 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

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


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/84bf337289e416ae. Report an issue: GitHub.