jesseduffield/lazygit · error

Git command failed. Check command log for details (open with

Error message

Git command failed. Check command log for details (open with %s)

What it means

GpgHelper.runAndStream (pkg/gui/controllers/helpers/gpg_helper.go) runs a git command with streamed output inside WithWaitingStatus (used for signing operations like creating a signed commit or tag). If the command exits non-zero it refreshes with failure options and returns the translated GitCommandFailed message pointing at the command log, which is opened with the ExtrasMenu keybinding.

Source

Thrown at pkg/gui/controllers/helpers/gpg_helper.go:92

		return err
	}

	return self.runAndStream(
		cmdObj, waitingStatus, onSuccess, failureRefreshOptions, successRefreshOptions)
}

func (self *GpgHelper) runAndStream(
	cmdObj *oscommands.CmdObj,
	waitingStatus string,
	onSuccess func() error,
	failureRefreshOptions types.RefreshOptions,
	successRefreshOptions types.RefreshOptions,
) error {
	return self.c.WithWaitingStatus(waitingStatus, func(gocui.Task) error {
		if err := cmdObj.StreamOutput().Run(); err != nil {
			self.c.RefreshFromWorker(failureRefreshOptions)
			return fmt.Errorf(
				self.c.Tr.GitCommandFailed, self.c.UserConfig().Keybinding.Universal.ExtrasMenu,
			)
		}

		if onSuccess != nil {
			if err := onSuccess(); err != nil {
				return err
			}
		}

		self.c.RefreshFromWorker(successRefreshOptions)
		return nil
	})
}

View on GitHub (pinned to c477a2959b)

Solutions

  1. Open the command log with the extras menu key (shown in the error, default '@') and read the actual git stderr.
  2. If it is a key problem: gpg --list-secret-keys --keyid-format long, ensure the key exists and git config user.signingkey points at it.
  3. Test outside lazygit with the same command (e.g. git commit -S --amend --no-edit) to reproduce and fix the gpg error.
  4. For SSH sessions, enable gpg-agent forwarding or use pinentry-tty; as a stopgap, temporarily unset commit.gpgsign for the repo.

Example fix

# terminal
# verify a signing key exists and is usable
gpg --list-secret-keys --keyid-format long
git config --global user.signingkey <KEYID>
git commit -S --allow-empty -m test  # reproduce outside lazygit
Defensive patterns

Strategy: try-catch

Validate before calling

// Precondition check before a signed operation:
if signingKey, _ := gitConfig("user.signingkey"); signingKey == "" {
	return errors.New("user.signingkey unset; signed commits will fail")
}

Try / catch

if err := runSignedGitCmd(); err != nil {
	log.Debugf("stderr captured in command log: %v", err)
	return fmt.Errorf("git failed; open the command log with %s", extrasKey)
}

Prevention

When it happens

Trigger: Creating/adjusting a signed commit or tag when the underlying `git commit -S` / `git tag -s` fails: missing GPG secret key, expired key, gpg not installed, pinentry cannot ask for the passphrase in the TUI, or commit.gpgsign=true with no signing key configured.

Common situations: Fresh machines without the signing key imported; ssh/gpg-agent forwarding not set up over SSH; commit.gpgsign enabled globally while working on a repo without signing configured; pinentry-tty vs pinentry mismatches.

Related errors


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