npx skills add https://github.com/mthines/gw-tools --skill config-managementSKILL.md
Configuration Management - Comprehensive Guide
This guide teaches you how to configure gw for optimal workflows across different project types.
Table of Contents
- Understanding gw Configuration
- Configuration Options Reference
- Auto-Copy Strategies
- Project-Type Configuration Patterns
- Team Configuration Management
- Advanced Configuration Techniques
- Troubleshooting Configuration
1. Understanding gw Configuration
Config File Location
gw stores configuration at .gw/config.json in your repository:
/projects/myapp.git/
├── main/ # Main worktree
│ ├── src/
│ ├── .gw/
│ │ └── config.json # ← Configuration file
│ └── package.json
├── feature-a/ # Other worktrees
└── feature-b/
Auto-Detection vs Manual Configuration
Auto-detection (recommended for most cases):
$ cd /projects/myapp/main
$ gw init
Repository root detected: /projects/myapp.git
Default branch detected: main
Configuration created at .gw/config.json
gw automatically detects:
- Repository root (parent directory containing worktrees)
- Default branch (main, master, or current branch)
Manual configuration (when auto-detection fails):
$ gw init --root /projects/myapp.git \
--default-branch main \
--auto-copy-files .env,.env.local,secrets/
Configuration Scope
Configuration is per-repository, not global:
- Each repository has its own
.gw/config.json - Different repos can have different configurations
- Configuration is shared across all worktrees in that repo
Config Precedence and Defaults
If no configuration exists:
gwsearches for.gw/config.jsonwalking up from current directory- If not found, attempts auto-detection on first
gw addcommand - Uses fallback defaults:
root: Auto-detected fromgit worktree listdefaultBranch: "main"autoCopyFiles:[](nothing copied automatically)
2. Configuration Options Reference
Complete Configuration Structure
{
"root": "/absolute/path/to/repo.git",
"defaultBranch": "main",
"autoCopyFiles": [
".env",
".env.local",
"secrets/",
"config/local.json"
],
"cleanThreshold": 7
}
root: Repository Root Path
Purpose: Absolute path to the parent directory containing all worktrees.
Example:
{
"root": "/Users/you/projects/myapp.git"
}
How it's used:
- Resolving worktree names to absolute paths
- Finding source files for auto-copy
- Determining worktree relationships
When to set manually:
- Auto-detection fails (unusual directory structure)
- Repository has non-standard naming
- Using symlinks or network drives
defaultBranch: Default Source Worktree
Purpose: Which worktree to copy files from by default.
Example:
{
"defaultBranch": "develop"
}
Common values:
"main"- Most projects"master"- Older projects"develop"- Gitflow workflow"staging"- Copy from staging environment
How it's used:
gw add feature-xcopies fromdefaultBranchworktreegw sync target file.txtsyncs fromdefaultBranchunless--fromspecifiedgw sync target(without files) syncsautoCopyFilesfromdefaultBranch
autoCopyFiles: File Patterns to Auto-Copy
Purpose: Files/directories automatically copied when creating worktrees.
Example:
{
"autoCopyFiles": [
".env",
".env.local",
"secrets/api-keys.json",
"config/",
"ssl/"
]
}
Pattern types:
- Exact files:
".env"- Single file - Directories:
"secrets/"- Entire directory (recursive) - Nested paths:
"config/local.json"- Specific nested file
How it's used:
gw add feature-xautomatically copies these files when creating worktreesgw sync feature-x(without file arguments) syncs these files to existing worktrees
Important notes:
- Paths are relative to repository root
- Directories should end with
/ - Files are copied, not symlinked
- Non-existent files are skipped with warning
cleanThreshold: Worktree Cleanup Age
Purpose: Number of days before worktrees are considered stale for gw clean.
Example:
{
"cleanThreshold": 7
}
Common values:
7- Default (one week)14- Two weeks (more lenient)3- Three days (aggressive cleanup)30- One month (very lenient)
How it's used:
gw cleanremoves worktrees older than this threshold- Only removes worktrees with no uncommitted changes and no unpushed commits (unless
--force) gw clean --dry-runpreviews which worktrees would be removed
Setting the threshold:
# Set during initializat
...