{"record":{"id":"f9bcf0ebb056a692","repo":"gastownhall/beads","slug":"not-in-a-git-repository-f9bcf0","errorCode":null,"errorMessage":"not in a git repository","messagePattern":"not in a git repository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_team.go","lineNumber":34,"sourceCode":"func runTeamWizard(ctx context.Context, store storage.DoltStorage) error {\n\tfmt.Printf(\"\\n%s %s\\n\\n\", ui.RenderBold(\"bd\"), ui.RenderBold(\"Team Workflow Setup Wizard\"))\n\tfmt.Println(\"This wizard will configure beads for team collaboration.\")\n\tfmt.Println()\n\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\treader := bufio.NewReader(os.Stdin)\n\n\t// Step 1: Check if we're in a git repository\n\tfmt.Printf(\"%s Detecting git repository setup...\\n\", ui.RenderAccent(\"▶\"))\n\n\tif !isGitRepo() {\n\t\tfmt.Printf(\"%s Not in a git repository\\n\", ui.RenderWarn(\"⚠\"))\n\t\tfmt.Println(\"\\n  Initialize git first:\")\n\t\tfmt.Println(\"  git init\")\n\t\tfmt.Println()\n\t\treturn fmt.Errorf(\"not in a git repository\")\n\t}\n\n\t// Get current branch\n\tcurrentBranch, err := getGitBranch()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get current branch: %w\", err)\n\t}\n\n\tfmt.Printf(\"%s Current branch: %s\\n\", ui.RenderPass(\"✓\"), currentBranch)\n\n\t// Step 2: Check for protected main branch\n\tfmt.Printf(\"\\n%s Checking branch configuration...\\n\", ui.RenderAccent(\"▶\"))\n\n\tfmt.Println(\"\\nIs your main branch protected (prevents direct commits)?\")\n\tfmt.Println(\"  GitHub: Settings → Branches → Branch protection rules\")\n\tfmt.Println(\"  GitLab: Settings → Repository → Protected branches\")\n\tfmt.Print(\"\\nProtected main branch? [y/N]: \")\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_team.go#L16-L52","documentation":"runTeamWizard refuses to run when the current working directory is not inside a git repository; isGitRepo() returns false and the wizard returns the sentinel error \"not in a git repository\" after printing guidance to run `git init`. The team wizard operates on branches and repo state, so a git repo is a hard prerequisite.","triggerScenarios":"Invoking `bd team` (the team wizard) from a directory with no .git anywhere up the tree: a fresh uninitialized project, a subdirectory outside any clone, a repo where .git was deleted/corrupted, or after running bd from a parent directory above the clone.","commonSituations":"Developer downloads beads and runs `bd team` before ever running `git init`; running in a temp/scratch directory that was never a repo; .git removed accidentally or the folder was copied without hidden files (e.g. via a tool that skips dotfiles); invoking from a git worktree-adjacent or bare-clone path where the check's cwd expectation fails.","solutions":["Initialize a repository in the project root: git init, then re-run bd team.","cd into your existing clone/repo root (or any directory inside it) before running `bd team`.","If .git is missing but the project should be a repo, re-clone or restore .git (e.g. git init && git remote add origin ... && git fetch).","If .git exists but is corrupted (isGitRepo false), back up files, run git init, and reattach the remote."],"exampleFix":"// before\n$ cd /tmp/new-project && bd team\n⚠ Not in a git repository\nerror: not in a git repository\n\n// after\n$ cd /tmp/new-project && git init && bd team\n✔ Team wizard started","handlingStrategy":"validation","validationCode":"// Go caller: replicate the guard before invoking the wizard\ncmd := exec.Command(\"git\", \"rev-parse\", \"--is-inside-work-tree\")\nif out, err := cmd.Output(); err != nil || strings.TrimSpace(string(out)) != \"true\" {\n\treturn fmt.Errorf(\"bd team requires a git repository; run 'git init' first\")\n}\n// Shell caller: git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { git init; }","typeGuard":null,"tryCatchPattern":"if err := runTeamWizard(cmd, args); err != nil {\n\tif err.Error() == \"not in a git repository\" {\n\t\tfmt.Println(\"Prerequisite missing: initialize git with 'git init', then re-run the wizard.\")\n\t\tos.Exit(1)\n\t}\n\treturn err\n}","preventionTips":["Always run git init as the first step of a new project, before bd team/init workflows.","Run bd commands from inside the repository working tree, not a parent directory.","When copying projects between machines/tools, preserve dotfiles (.git included).","Add a preflight `git rev-parse --is-inside-work-tree` check to scripts that wrap bd team."],"tags":["git","prerequisite","repository","cli","wizard"],"backgroundTag":"not-a-git-repository","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}