gastownhall/beads · error
not in a git repository
Error message
not in a git repository
What it means
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.
Source
Thrown at cmd/bd/init_team.go:34
func runTeamWizard(ctx context.Context, store storage.DoltStorage) error {
fmt.Printf("\n%s %s\n\n", ui.RenderBold("bd"), ui.RenderBold("Team Workflow Setup Wizard"))
fmt.Println("This wizard will configure beads for team collaboration.")
fmt.Println()
if ctx == nil {
ctx = context.Background()
}
reader := bufio.NewReader(os.Stdin)
// Step 1: Check if we're in a git repository
fmt.Printf("%s Detecting git repository setup...\n", ui.RenderAccent("▶"))
if !isGitRepo() {
fmt.Printf("%s Not in a git repository\n", ui.RenderWarn("⚠"))
fmt.Println("\n Initialize git first:")
fmt.Println(" git init")
fmt.Println()
return fmt.Errorf("not in a git repository")
}
// Get current branch
currentBranch, err := getGitBranch()
if err != nil {
return fmt.Errorf("failed to get current branch: %w", err)
}
fmt.Printf("%s Current branch: %s\n", ui.RenderPass("✓"), currentBranch)
// Step 2: Check for protected main branch
fmt.Printf("\n%s Checking branch configuration...\n", ui.RenderAccent("▶"))
fmt.Println("\nIs your main branch protected (prevents direct commits)?")
fmt.Println(" GitHub: Settings → Branches → Branch protection rules")
fmt.Println(" GitLab: Settings → Repository → Protected branches")
fmt.Print("\nProtected main branch? [y/N]: ")
View on GitHub (pinned to 71377f2769)
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.
Example fix
// before $ cd /tmp/new-project && bd team ⚠ Not in a git repository error: not in a git repository // after $ cd /tmp/new-project && git init && bd team ✔ Team wizard started
Defensive patterns
Strategy: validation
Validate before calling
// Go caller: replicate the guard before invoking the wizard
cmd := exec.Command("git", "rev-parse", "--is-inside-work-tree")
if out, err := cmd.Output(); err != nil || strings.TrimSpace(string(out)) != "true" {
return fmt.Errorf("bd team requires a git repository; run 'git init' first")
}
// Shell caller: git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { git init; } Try / catch
if err := runTeamWizard(cmd, args); err != nil {
if err.Error() == "not in a git repository" {
fmt.Println("Prerequisite missing: initialize git with 'git init', then re-run the wizard.")
os.Exit(1)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- auto-export: git add failed: %w
- not in a git repository
- failed to read .gitignore: %w
- failed to write .gitignore: %w
- failed to get current branch: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/f9bcf0ebb056a692.
Report an issue: GitHub.