{"record":{"id":"7395a9b1e4ff2237","repo":"jesseduffield/lazygit","slug":"lazygit-does-not-support-bare-repos","errorCode":null,"errorMessage":"Lazygit does not support bare repos.","messagePattern":"Lazygit does not support bare repos\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/git.go","lineNumber":75,"sourceCode":"}\n\nfunc NewGitCommand(\n\tcmn *common.Common,\n\tversion *git_commands.GitVersion,\n\tosCommand *oscommands.OSCommand,\n\tgitConfig git_config.IGitConfig,\n\tdiffRendererConfigManager *config.DiffRendererConfigManager,\n) (*GitCommand, error) {\n\trepoPaths, err := git_commands.GetRepoPaths(osCommand.Cmd, version)\n\tif err != nil {\n\t\treturn nil, errors.Errorf(\"Error getting repo paths: %v\", err)\n\t}\n\n\t// A bare repo has no worktree for us to work in. Callers that can offer the\n\t// user something better (app.setupRepo) check for this first; getting here\n\t// means nobody could, e.g. because --git-dir was pointed at a bare repo.\n\tif repoPaths.IsBareRepo() {\n\t\treturn nil, errors.New(cmn.Tr.BareRepoNotSupported)\n\t}\n\n\terr = os.Chdir(repoPaths.WorktreePath())\n\tif err != nil {\n\t\treturn nil, utils.WrapError(err)\n\t}\n\n\t// Everything we run through the command builder gets told where the repo is\n\t// by the builder itself, but subprocesses don't go through it: user-defined\n\t// custom commands, an editor, and the lazygit we re-enter as git's sequence\n\t// editor during a rebase. Put it in the process env for those.\n\tenv.SetGitLocationEnvVars(repoPaths.GitLocationEnvVars())\n\n\t// Pin the config reads to the repo directory like all other git commands\n\t// (see NewGitCmdObjBuilder); the config commands run outside that builder.\n\tgitConfig.SetDir(repoPaths.WorktreePath())\n\n\treturn NewGitCommandAux(","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/commands/git.go#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"Servers holding central bare repos; users mistaking a bare repo for a normal clone; automations that reuse remote-storage repos.","solutions":["Open a normal (non-bare) clone or attach a worktree to the bare repo and open lazygit there","If you only meant to browse, clone the repo: `git clone /repo.git` and run lazygit in the clone","If the repo was accidentally initialized bare, recreate it non-bare or unset core.bare with a worktree configured"],"exampleFix":"# before\nlazygit --path=/srv/git/project.git   # bare repo -> error\n\n# after\ngit clone /srv/git/project.git ~/src/project\nlazygit --path ~/src/project","handlingStrategy":"validation","validationCode":"// before building commands for a repo path:\nout, _ := exec.Command(\"git\", \"-C\", path, \"rev-parse\", \"--is-bare-repository\").Output()\nif strings.TrimSpace(string(out)) == \"true\" {\n    // offer clone/worktree instead of proceeding\n}","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Check `git rev-parse --is-bare-repository` in launcher scripts before opening lazygit","Never point --git-dir or --path at *.git directories used as remotes","Serve bare repos; work in clones or linked worktrees"],"tags":["git","bare-repo","worktree","startup"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}