Skip to content

Developer Instructions could include advice on creating a worktree #102

@dougransom

Description

@dougransom

To set this up cleanly in PowerShell, we will create a parent directory and then use the git clone --bare or "move and repair" strategy. However, the most straightforward way for a fresh setup is to treat one directory as your "base" and add the others as worktrees alongside it.

Here are the PowerShell commands to build your workspace from scratch.


1. Create the Project Parent Directory

First, move out of your current folder and create the container for all your worktrees.

# Create and enter the parent directory
New-Item -Path "C:\Users\doug\code\dtactions-workspace" -ItemType Directory
Set-Location "C:\Users\doug\code\dtactions-workspace"

2. Initialize the "Main" Worktree

We will clone the repository into the main folder. This will serve as your primary repo where the .git data actually lives.

# Clone the 'dt' version into a folder named 'main'
git clone https://github.com/dictation-toolbox/dtactions.git main
Set-Location .\main

# Set up your remotes
git remote add doug https://github.com/dougransom/dtactions.git
git remote rename origin dt
# (Optional) upstream is the same as dt in your config
git remote add upstream https://github.com/dictation-toolbox/dtactions.git

# Fetch all data from all remotes
git fetch --all

3. Create the "Broke" Worktree

Now, while still inside the main folder, tell Git to create a second working directory one level up.

# Add worktree: Path is ../broke_dtactions_unimacro 
# The branch is tracked from the 'doug' remote
git worktree add ../broke_dtactions_unimacro -b broke_dtactions_unimacro doug/broke_dtactions_unimacro

4. Verify Your Setup

You can now see how Git is managing these separate folders.

# List all active worktrees
git worktree list

Summary of Directory Result

Your folder structure will now look like this:

  • C:\Users\doug\code\dtactions-workspace\
    • main\ (Running the main branch from dt)
    • broke_dtactions_unimacro\ (Running the broke... branch from doug)

A Quick Tip for PowerShell: When you switch between these folders, remember that each folder has its own "checked out" state. If you run git status in main, it shows the status of the main branch. If you cd ..\broke_dtactions_unimacro and run git status, it shows the status for your specific feature branch. Both utilize the exact same .git database stored in the main folder.

Since you mentioned you want to "run each one as you see fit," do you need help setting up separate Python virtual environments for each worktree so their dependencies don't clash?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions