Syntax
Description
Therepo convert command transforms a standard Git repository into a bare + worktree layout. This enables efficient management of multiple branches as separate working directories.
Arguments
Path to the Git repository to convert. If omitted, converts the current directory.
How It Works
- Validates that the target is a standard Git repository
- Determines the current branch
- Moves
.gitdirectory to.bare - Creates a
.gitfile pointing to.bare - Configures the repository for worktree use
- Creates a subdirectory named after the current branch
- Moves all working files into that subdirectory
- Registers the subdirectory as a worktree
- Sets up upstream tracking
Examples
Convert current directory
Convert specific repository
Convert after moving to REPO_BASE_DIR
Before and After
Before Conversion
After Conversion
Behavior
Successful Conversion
Already Converted
If the repository already uses worktree layout:Not a Git Repository
Inside a Worktree
Detached HEAD
Configuration Changes
The conversion process modifies Git configuration:Related Commands
- repo get - Clone new repositories with worktree layout from the start
- repo wt - Manage worktrees after conversion
- repo goto - Navigate between worktrees
Common Use Cases
Migrate existing projects
Convert multiple repositories
Prepare for multi-branch development
Advantages After Conversion
Work on multiple branches simultaneously - Each branch has its own directory
Avoid stashing and checkout conflicts - Switch between features instantly by changing directories
Run builds in parallel - Test different branches without interference
Better IDE support - Each worktree can have its own editor window with correct file state
Tips
After conversion, you can create additional worktrees with
repo wt add <branch-name>.Implementation Details
Source code:functions/convert.zsh:1
The conversion process:
-
Validation (
convert.zsh:4-18)- Checks for
.gitdirectory - Ensures it’s not already converted
- Verifies it’s not a worktree
- Checks for
-
Branch Detection (
convert.zsh:22-27)- Uses
git branch --show-current - Fails if in detached HEAD state
- Uses
-
Restructuring (
convert.zsh:29-58)- Moves
.git→.bare - Creates
.gitfile pointing to.bare - Moves all files into branch-named subdirectory
- Handles both regular files and dotfiles
- Moves
-
Git Configuration (
convert.zsh:36-62)- Configures fetch refspec
- Registers worktree with Git
- Sets up upstream tracking
-
Worktree Registration (
convert.zsh:61-76)- Creates worktree admin directory
- Links worktree to bare repository
- Ensures proper Git metadata