A Copy-on-Write Git Worktree Manager that combines filesystem-level CoW features with git worktrees to create instant, fully-featured development environments.
- Instant environment setup: Create working copies of projects in ~1 second instead of 10-30+ seconds
- Complete isolation: Each worktree can modify dependencies without affecting others
- Zero manual setup: No need to run
npm install,pip install,go mod download, etc. - Git integration: Proper git worktree management with branch tracking
- Full compatibility: Drop-in replacement for
git worktreecommands - Cross-platform: Support macOS (APFS) and Linux (overlayfs - coming soon)
go build -o coworktreeCoWorktree is fully compatible with git worktree commands - just replace git worktree with coworktree:
# Create worktree at path (auto-generates branch name)
coworktree add ../feature-work
# Create worktree with specific branch name
coworktree add -b my-feature ../feature-work
# Create from specific commit
coworktree add ../hotfix abc123
# Create in temp directory (if no path specified)
coworktree add -b experimentThis will:
- Create a CoW clone of your entire project (including
node_modules, build artifacts, etc.) - Create a new git branch in the worktree
- Register the worktree with git
- Preserve all untracked and gitignored files
coworktree list
# Forwards directly to: git worktree listcoworktree remove ../feature-work
# Forwards directly to: git worktree remove ../feature-work--verbose, -v: Enable verbose logging--dry-run: Show what would be done without executing--no-cow: Force traditional git worktree (skip CoW)--no-rewrite: Skip absolute path rewriting in gitignored files
package main
import (
"fmt"
"log"
"coworktree/pkg/cowgit"
)
func main() {
// Create a new CoW worktree directly
repoPath := "."
worktreePath := "/tmp/my-feature"
branchName := "my-feature"
worktree := cowgit.NewWorktree(repoPath, worktreePath, branchName)
// Check if CoW is supported
if supported, err := cowgit.IsCoWSupported(repoPath); err == nil && supported {
// Create CoW worktree
if err := worktree.CreateCoWWorktree(); err != nil {
log.Fatal(err)
}
fmt.Printf("Created CoW worktree at: %s\n", worktree.WorktreePath)
} else {
// Fall back to regular worktree
if err := worktree.CreateFromExistingBranch(); err != nil {
log.Fatal(err)
}
fmt.Printf("Created regular worktree at: %s\n", worktree.WorktreePath)
}
// List all worktrees
worktrees, err := cowgit.ListWorktrees(repoPath)
if err != nil {
log.Fatal(err)
}
for _, wt := range worktrees {
fmt.Printf("Branch: %s, Path: %s\n", wt.Branch, wt.Path)
}
}- Uses
clonefile()syscall for true copy-on-write - Instant cloning regardless of project size
- Requires APFS filesystem (default on modern macOS)
- Coming soon
- Will use kernel overlayfs for CoW functionality
- Automatically falls back to traditional
git worktreeon unsupported platforms - Graceful degradation ensures compatibility everywhere
CoWorktree leverages filesystem-level copy-on-write features to create instant copies of your entire project directory, including:
- Source code
- Dependencies (
node_modules,venv,vendor, etc.) - Build artifacts
- IDE configuration
- Any other project files
The CoW clone shares storage with the original until files are modified, making it extremely space-efficient while providing complete isolation.
- Feature development: Quickly spin up isolated environments for different features
- Experimentation: Test dependency updates without affecting main environment
- Parallel work: Multiple developers/agents working on same project simultaneously
- Code review: Quickly checkout PRs with full working environment
- CI/CD: Faster build environments with pre-installed dependencies
On a typical Node.js project with 18k+ files in node_modules:
- Traditional
git worktree+npm install: 30-60 seconds - CoWorktree: <2 seconds
go test ./pkg/cowgit -vTests cover:
- CoW functionality on APFS
- Git worktree integration
- Preservation of untracked and gitignored files
- Large project handling
- Cross-platform compatibility
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License