A Python CLI tool for managing paired Git worktrees with different .gitignore rules.
ddworktree simplifies working with paired Git worktrees where you need different .gitignore rules for main and local development. This is particularly useful for:
- Keeping generated files, build artifacts, or local configuration files in your local worktree
- Maintaining clean commits in your main worktree
- Automatically syncing changes between paired worktrees
- Detecting and managing drift between worktrees
- Paired Worktree Management: Create and manage pairs of main and local worktrees
- Intelligent .gitignore Handling: Different ignore rules for each worktree
- Automatic Synchronization: Sync changes between paired worktrees
- Drift Detection: Identify differences between worktrees
- Git Operations: Perform Git operations across paired worktrees
- Configuration Management: Flexible configuration with TOML/YAML support
# Clone the repository
git clone <repository-url>
cd ddworktree
# Install the package
pip install -e .
# Or install dependencies manually
pip install GitPython toml-
Initialize ddworktree in your repository:
cd your-repo ddworktree init -
Add a paired local worktree:
ddworktree add
-
Work in your local worktree:
cd your-repo-local # Make changes, add generated files, etc.
-
Sync with main worktree:
ddworktree sync
ddworktree add- Add a paired local worktreeddworktree list- List all worktreesddworktree remove- Remove a worktree
ddworktree add <files>- Add files to stagingddworktree commit <message>- Commit changesddworktree reset <files>- Reset filesddworktree rm <files>- Remove filesddworktree mv <src> <dest>- Move files
ddworktree fetch- Fetch from remoteddworktree pull- Pull from remoteddworktree push- Push to remoteddworktree merge- Merge branchesddworktree rebase- Rebase branchesddworktree cherry-pick- Cherry-pick commits
ddworktree drift- Show drift between worktreesddworktree sync- Sync changes between worktrees
ddworktree status- Show status of paired worktreesddworktree diff- Show differences between worktrees
ddworktree pair- Pair worktreesddworktree unpair- Unpair worktreesddworktree doctor- Check worktree healthddworktree restore- Restore missing worktrees
ddworktree clone <url>- Clone with paired worktreesddworktree logs- Show commit logsddworktree config- Manage configuration
ddworktree uses a flexible configuration system that supports TOML and YAML formats. The configuration file is located at .ddworktree/config.toml (or .ddworktree/config.yaml).
[pairs]
my-project = "/path/to/main /path/to/local"
[options]
local_suffix = "-local"
auto_sync = "true"
push_local = "false"
default_branch = "main"
sync_on_commit = "true"
verbose = "false"
dry_run_default = "false"local_suffix: Suffix for local worktree directories (default: "-local")auto_sync: Automatically sync changes between worktrees (true/false)push_local: Include local commits when pushing (true/false)default_branch: Default branch for new worktreessync_on_commit: Automatically sync paired worktree after commit (true/false)verbose: Enable verbose output by default (true/false)dry_run_default: Default to dry-run mode for destructive operations (true/false)
ddworktree creates pairs of worktrees:
- Main worktree: Your primary development environment
- Local worktree: Contains files you want to keep out of version control
Each worktree has its own .gitignore rules:
- Main worktree: Uses
.gitignore - Local worktree: Uses
.gitignore+.gitignore-local
ddworktree automatically syncs:
- Files that exist in both worktrees
- Files that match the main worktree's .gitignore rules
- Files explicitly added to staging
- Keep track of your or your agent's ai generated memory files
- Keep generated files, build artifacts, or local configuration in your local worktree
- Maintain clean commits with only source code in your main worktree
- Try out experimental changes in your local worktree
- Sync only the working changes back to your main worktree
- use a tool like uzi to develop and compare the same feature in parallel with independent environemnts with having to go down a docker hole https://github.com/devflowinc/uzi
- Share your main worktree with the team
- Keep personal development files in your local worktree
# Initialize ddworktree
ddworktree init
# Add a paired local worktree
ddworktree add
# Check status
ddworktree status# In main worktree
echo "print('Hello')" > main.py
ddworktree add main.py
ddworktree commit "Add main.py"
# In local worktree
cd myproject-local
echo "print('Debug info')" > debug.py
echo "debug.py" >> .gitignore-local
# Sync changes to main worktree
ddworktree sync# Clone repository with paired worktree
ddworktree clone https://github.com/user/repo.git
# Clone without local worktree
ddworktree clone https://github.com/user/repo.git --no-localRun the test suite:
python -m pytest tests/- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
- Python 3.7+
- Git
- GitPython
- tomllib (Python 3.11+)
For issues and questions, please open an issue on the GitHub repository.