git-worktree-manager
Git Worktree Manager
Manage git worktrees to enable parallel multi-branch development while keeping the main working directory clean.
Recommended Directory Structure
project/
├── main-repo/ # Main working directory
└── worktrees/ # All worktrees here
├── feature/name/
├── bugfix/name/
└── experiment/name/
Core Commands
Create Worktree
# From existing branch
git worktree add ../worktrees/feature-name feature-branch
# Create new branch
git worktree add -b feature/new ../worktrees/new-feature
# Detached HEAD (specific commit)
git worktree add ../worktrees/temp HEAD~5
List Worktrees
git worktree list
git worktree list --porcelain # Machine-readable
Remove Worktree
git worktree remove ../worktrees/name # Safe (clean only)
git worktree remove --force ../worktrees/name # Force removal
git worktree prune # Clean administrative data
Lock/Unlock
git worktree lock ../worktrees/name # Prevent operations
git worktree unlock ../worktrees/name
Workflow Patterns
Feature Development
git worktree add -b feature/new ../worktrees/feature/new
cd ../worktrees/feature/new
# ... develop ...
cargo test # Test in isolation
git push
cd /path/to/main && git merge feature/new
git worktree remove ../worktrees/feature/new
Parallel Testing
for branch in feature/a feature/b; do
git worktree add ../worktrees/$branch $branch
cd ../worktrees/$branch && cargo test &
done
wait
Code Review
git worktree add ../worktrees/review/pr-123 origin/pr-123
cd ../worktrees/review/pr-123
cargo test
git worktree remove ../worktrees/review/pr-123
Find Orphaned Worktrees
git worktree list | while read path commit branch; do
if ! git show-ref --verify --quiet "refs/heads/${branch#*/}"; then
echo "Orphaned: $path"
fi
done
Best Practices
DO
- Organize in
../worktrees/directory - Use descriptive branch-based names
- Clean up after merging
- Test before merging to main
- Prune regularly to remove orphaned data
DON'T
- Create in random locations
- Leave with uncommitted changes
- Forget to prune administrative data
- Create conflicting branches
- Mix worktree/non-worktree workflows
More from d-o-hub/rust-self-learning-memory
loop-agent
Execute workflow agents iteratively for refinement and progressive improvement until quality criteria are met. Use when tasks require repetitive refinement, multi-iteration improvements, progressive optimization, or feedback loops until convergence.
51web-search-researcher
Research topics using web search and content fetching to find accurate, current information. Use when you need modern information, official documentation, best practices, technical solutions, or comparisons beyond your training data.
46perplexity-researcher-reasoning-pro
Highest level of research and reasoning capabilities for complex decision-making with significant consequences, strategic planning, technical architecture decisions, multi-stakeholder problems, or high-complexity troubleshooting requiring expert-level judgment and sophisticated reasoning chains. Prioritizes actively maintained repositories and validates website sources for 2025 relevance.
44context-retrieval
Retrieve relevant episodic context from memory for informed decision-making. Use when you need past episodes, patterns, or solutions to similar tasks.
44rust-code-quality
Perform comprehensive Rust code quality reviews against best practices for async Rust, error handling, testing, and project structure
43codebase-analyzer
Analyze implementation details, trace data flow, explain technical workings, locate files, and consolidate codebases. Use when you need to understand HOW code works, find file locations, or assess technical debt.
40