jesseduffield/lazygit · warning
There's no commit to amend.
Error message
There's no commit to amend.
What it means
Thrown by FilesController.handleAmendCommitPress when Model().Commits is empty at the moment of amending. Amending rewrites HEAD; with no commits loaded there is no HEAD to amend (empty repository, or the commits model is not populated yet). The check runs inside WithEnsureCommittableFiles so it only fires once there are committable files, meaning the user genuinely tried to amend in a repo whose history is empty.
Source
Thrown at pkg/gui/controllers/files_controller.go:1071
}
return nil
},
Keys: menuKey('e'),
},
},
})
}
func (self *FilesController) refresh() error {
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}})
return nil
}
func (self *FilesController) handleAmendCommitPress() error {
doAmend := func() error {
return self.c.Helpers().WorkingTree.WithEnsureCommittableFiles(func() error {
if len(self.c.Model().Commits) == 0 {
return errors.New(self.c.Tr.NoCommitToAmend)
}
return self.c.Helpers().AmendHelper.AmendHead()
})
}
if self.isResolvingConflicts() {
return self.c.Menu(types.CreateMenuOptions{
Title: self.c.Tr.AmendCommitTitle,
Prompt: self.c.Tr.AmendCommitWithConflictsMenuPrompt,
HideCancel: true, // We want the cancel item first, so we add one manually
Items: []*types.MenuItem{
{
Label: self.c.Tr.Cancel,
OnPress: func() error {
return nil
},
},View on GitHub (pinned to c477a2959b)
Solutions
- Make a normal initial commit instead ('c' commit) — amend needs an existing HEAD
- If history exists but is not shown, refresh ('r') and confirm the commits panel is populated before amending
Example fix
# before: empty repo, shift+A errors git add -A && git commit -m 'initial' # use commit, not amend # after: repo has HEAD, amend works git commit --amend --no-edit
Defensive patterns
Strategy: validation
Validate before calling
// Require a populated commit model before amending:
if len(model.Commits) == 0 {
return errors.New("no commit to amend: create an initial commit first")
} Prevention
- Hide/disable the amend action in repositories without HEAD
- Detect empty history with 'git rev-parse --verify HEAD' in scripts before --amend
- Offer plain commit as the fallback in empty repos
When it happens
Trigger: Pressing shift+A (amend commit) in the files panel of a brand-new repository with staged files but zero commits, i.e. the very first commit does not exist yet.
Common situations: Fresh 'git init' repositories where users stage everything then press amend by habit; or a repo whose commits panel has not loaded (huge repo, slow load) though the empty-history case is the real trigger.
Related errors
- Git version must be at least %s. Please upgrade your git ver
- Lazygit does not support bare repos.
- unexpected git output
- Must specify a remote if specifying a branch
- Expected renamed file
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/c944078bb2fd876a.
Report an issue: GitHub.