Skip to content

Add git gtr copy command for syncing files between worktrees #29

@b-barry

Description

@b-barry

Problem

When working with multiple worktrees, developers often need to sync configuration files (especially .env files) from the main repo to worktrees after they've been created.

Current workflow requires manual commands:

cd /path/to/main-repo && find . -name ".env*" -type f -exec sh -c \
  'mkdir -p "/path/to/worktree/$(dirname "$1")" && cp "$1" "/path/to/worktree/$1"' _ {} \;

This is verbose, error-prone, and breaks the DX that gtr provides.

Proposed Solution

Add a git gtr copy command:

git gtr copy 1 my-feature --pattern ".env*"

This would copy all matching files from the main repo to the worktree while preserving directory structure.

Use Cases

  • Created a worktree with --no-copy but now need env files
  • Updated .env in main and need to propagate to existing worktrees
  • Selective sync without running full postCreate hooks

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