Skip to content

Git initialization defaults to 'master' branch instead of 'main' #734

@JasonBroderick

Description

@JasonBroderick

Operating System

Linux (Docker container)

Run Mode

Docker

App Version

v0.14.0rc (bug also exists in v0.13.0)

Bug Description

When Automaker initializes a new project, it uses git init without specifying the initial branch name. This causes new projects to default to "master" instead of "main", which conflicts with GitHub's current standard (since 2020) and causes feature visibility issues when pushing to GitHub.

Root Cause Analysis

File: apps/server/src/routes/worktree/routes/init-git.ts:47

// Initialize git and create an initial empty commit
await execAsync(`git init && git commit --allow-empty -m "Initial commit"`, {
    cwd: projectPath,
});

The git init command relies on the system's default branch configuration. Even though the Docker container may have init.defaultBranch=main configured globally, it's better to be explicit to ensure consistent behavior across all environments.

Impact

  1. All features inherit wrong branch: When features are created, they get branchName: "master" in their feature.json files
  2. GitHub push creates mismatch: When pushing to GitHub (which defaults to "main"), there's a branch name mismatch
  3. Features disappear from UI: The Kanban board filters features by branch name, so features with branchName: "master" become invisible when the actual branch is "main"
  4. Manual fix required: Users must manually update all feature.json files to change branchName from "master" to "main"

Steps to Reproduce

  1. Create a new project in Automaker
  2. Run git branch in the project directory → shows "master"
  3. Create several features through Automaker UI
  4. Check .automaker/features/*/feature.json → all have "branchName": "master"
  5. Push to GitHub → GitHub creates "main" branch (GitHub default since 2020)
  6. Return to Automaker UI → all features have disappeared from Kanban board
  7. Check browser console → features are being filtered because branchName doesn't match current branch

Expected Behavior

  • New projects should be initialized on "main" branch to match modern GitHub standards
  • Features should automatically get branchName: "main"
  • No manual intervention required when pushing to GitHub

Suggested Fix

Update apps/server/src/routes/worktree/routes/init-git.ts:47 to explicitly specify the initial branch:

// Initialize git and create an initial empty commit
await execAsync(`git init --initial-branch=main && git commit --allow-empty -m "Initial commit"`, {
    cwd: projectPath,
});

The --initial-branch flag is supported in Git 2.28+ (July 2020), which should be available in all modern environments.

Additional Context

This issue affects all new projects created with Automaker. GitHub changed its default branch from "master" to "main" in October 2020, and most Git hosting platforms have followed suit. Automaker should align with this industry standard.

Related: Issue #735 proposes adding a feature migration tool when users rename git branches manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions