jesseduffield/lazygit · error

Lazygit does not support bare repos.

Error message

Lazygit does not support bare repos.

What it means

Returned by NewGitCommand when GetRepoPaths reports core.bare=true. A bare repo has no worktree, and every lazygit feature (status, staging, commits panel) operates on a worktree, so there is nothing it can offer. Callers like app.setupRepo normally intercept this earlier to suggest creating a clone/worktree; reaching this error means that path was unavailable, e.g. lazygit was launched with --git-dir pointing at a bare repo.

Source

Thrown at pkg/commands/git.go:75

}

func NewGitCommand(
	cmn *common.Common,
	version *git_commands.GitVersion,
	osCommand *oscommands.OSCommand,
	gitConfig git_config.IGitConfig,
	diffRendererConfigManager *config.DiffRendererConfigManager,
) (*GitCommand, error) {
	repoPaths, err := git_commands.GetRepoPaths(osCommand.Cmd, version)
	if err != nil {
		return nil, errors.Errorf("Error getting repo paths: %v", err)
	}

	// A bare repo has no worktree for us to work in. Callers that can offer the
	// user something better (app.setupRepo) check for this first; getting here
	// means nobody could, e.g. because --git-dir was pointed at a bare repo.
	if repoPaths.IsBareRepo() {
		return nil, errors.New(cmn.Tr.BareRepoNotSupported)
	}

	err = os.Chdir(repoPaths.WorktreePath())
	if err != nil {
		return nil, utils.WrapError(err)
	}

	// Everything we run through the command builder gets told where the repo is
	// by the builder itself, but subprocesses don't go through it: user-defined
	// custom commands, an editor, and the lazygit we re-enter as git's sequence
	// editor during a rebase. Put it in the process env for those.
	env.SetGitLocationEnvVars(repoPaths.GitLocationEnvVars())

	// Pin the config reads to the repo directory like all other git commands
	// (see NewGitCmdObjBuilder); the config commands run outside that builder.
	gitConfig.SetDir(repoPaths.WorktreePath())

	return NewGitCommandAux(

View on GitHub (pinned to c477a2959b)

Solutions

  1. Open a normal (non-bare) clone or attach a worktree to the bare repo and open lazygit there
  2. If you only meant to browse, clone the repo: `git clone /repo.git` and run lazygit in the clone
  3. If the repo was accidentally initialized bare, recreate it non-bare or unset core.bare with a worktree configured

Example fix

# before
lazygit --path=/srv/git/project.git   # bare repo -> error

# after
git clone /srv/git/project.git ~/src/project
lazygit --path ~/src/project
Defensive patterns

Strategy: validation

Validate before calling

// before building commands for a repo path:
out, _ := exec.Command("git", "-C", path, "rev-parse", "--is-bare-repository").Output()
if strings.TrimSpace(string(out)) == "true" {
    // offer clone/worktree instead of proceeding
}

Try / catch

If NewGitCommand returns BareRepoNotSupported, do not retry on the same path — either redirect the user to a worktree/clone or exit. There is no in-place workaround inside a bare repo.

Prevention

When it happens

Trigger: Running `lazygit --path=/repo.git --use-config-file` where the path is bare; opening a *.git directory directly; scripts invoking lazygit programmatically inside a bare repo used as a remote.

Common situations: Servers holding central bare repos; users mistaking a bare repo for a normal clone; automations that reuse remote-storage repos.

Related errors


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