Skip to content

Worktrees created from monorepos do not initialize git submodules #1187

@halindrome

Description

@halindrome

Summary

When git worktree add creates a new worktree from a monorepo that uses git submodules, the submodule directories in the new worktree are empty. Archon does not run git submodule update --init after worktree creation, so any workflow that needs to operate on submodule content will find empty directories.

Root Cause

WorktreeProvider.createWorktree() (packages/isolation/src/providers/worktree.ts) calls git worktree add without --recurse-submodules, and no git submodule update --init is run afterward. Git's default worktree add behavior creates the .gitmodules file but leaves submodule directories empty.

Expected Behavior

After worktree creation, submodules should be initialized and checked out so that workflows can operate on the full monorepo content.

Suggested Fix

After git worktree add succeeds in createNewBranch(), run:

git -C <worktreePath> submodule update --init --recursive

This should be conditional — only when the repo has a .gitmodules file — to avoid unnecessary overhead for repos without submodules. Consider making it configurable via .archon/config.yaml (worktree.initSubmodules: true/false).

Related

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions