jesseduffield/lazygit · warning
You cannot commit without a commit message
Error message
You cannot commit without a commit message
What it means
Returned by CommitsHelper.HandleCommitConfirm when the user confirms the commit-message panel but the summary line is empty (after TrimSpace). lazygit refuses to create a commit with no subject because git itself requires a non-empty message unless -m '' --allow-empty-message is used deliberately; the description alone is not enough.
Source
Thrown at pkg/gui/controllers/helpers/commits_helper.go:186
if initialMessageIsPreserved {
self.SetPreservedMessageInView(initialMessage)
} else {
self.SetMessageAndDescriptionInView(initialMessage)
}
self.c.Context().Push(self.c.Contexts().CommitMessage, types.OnFocusOpts{})
}
func (self *CommitsHelper) ClearPreservedCommitMessage() {
self.c.Contexts().CommitMessage.SetPreservedMessageAndLogError("")
}
func (self *CommitsHelper) HandleCommitConfirm() error {
summary, description := self.getCommitSummary(), self.getCommitDescription()
if strings.TrimSpace(summary) == "" {
return errors.New(self.c.Tr.CommitWithoutMessageErr)
}
err := self.c.Contexts().CommitMessage.OnConfirm(summary, description)
if err != nil {
return err
}
return nil
}
func (self *CommitsHelper) PreserveCommitMessage() {
if self.c.Contexts().CommitMessage.GetPreserveMessage() {
message := self.JoinCommitMessageAndUnwrappedDescription()
if message != self.c.Contexts().CommitMessage.GetInitialMessage() {
self.c.Contexts().CommitMessage.SetPreservedMessageAndLogError(message)
}
}
}View on GitHub (pinned to c477a2959b)
Solutions
- Type a non-empty summary on the first line of the commit panel, then confirm.
- Use Esc to abandon the commit instead of confirming an empty message.
- If you intended a message-less commit, that is unsupported by design; write a summary.
Defensive patterns
Strategy: validation
Validate before calling
// before confirming the panel:
if strings.TrimSpace(summary) == "" {
// abort silently (Esc semantics) instead of confirming
} Prevention
- Train Esc-to-cancel vs Enter-to-confirm muscle memory
- Rely on commit message templates to prefill a non-empty summary
When it happens
Trigger: Opening the commit message panel (c) and pressing Enter with an empty or whitespace-only summary, e.g. relying only on the description body, or after clearing a prefilled message to abort-but-actually-confirm.
Common situations: Users pressing Enter to 'close' the panel instead of Esc; template/prefix auto-fill producing an empty effective summary; clipboard paste landing in the description field instead of the summary.
Related errors
- No files staged
- Must specify a remote if specifying a branch
- Expected renamed file
- No changed files
- Invalid upstream. Must be in the format '<remote> <branchnam
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/ff4b25450012fd72.
Report an issue: GitHub.