workspaces
Twig uses workspaces to let you work on multiple tasks without conflicts. Each workspace is isolated, so changes in one don't affect others until you're ready to merge.
what is a workspace?
A workspace in twig is a separate working copy of your repository. Under the hood, it uses Git worktrees - a Git feature that allows multiple working directories from a single repository.
This means:
- Each workspace has its own files
- Changes are tracked separately
- You can switch between tasks instantly
- No need to stash or commit work-in-progress
why workspaces matter
context switching
Working on a feature when an urgent bug comes in? Create a new workspace for the bug fix without losing your feature work.
parallel development
Run multiple experiments simultaneously. Compare different approaches in separate workspaces.
clean separation
Keep unrelated changes apart. No more "I'll just add this quick fix to the same branch."
working with workspaces
creating a workspace
When you start a new task in twig, it creates a workspace automatically. Each workspace gets:
- A fresh copy of the repository
- Its own Git branch
- Isolated changes
switching workspaces
Switch between workspaces to move between tasks. Your changes in each workspace remain intact.
merging changes
When you're done with a task, the workspace changes can be committed and merged like any Git branch.
git worktrees explained
Git worktrees are a native Git feature (since Git 2.5). A worktree is an additional working directory attached to your repository.
Traditional Git workflow:
repo/
.git/
src/
...
With worktrees:
repo/
.git/
src/
...
repo-feature-a/ (worktree)
src/
...
repo-bugfix/ (worktree)
src/
...
All worktrees share the same .git directory, so:
- Branches are shared
- Commits are visible across worktrees
- Disk usage is minimal (only changed files are duplicated)
best practices
one task per workspace
Keep workspaces focused. If a task grows to include multiple unrelated changes, consider splitting it.
meaningful names
Name workspaces after what you're working on: "add-user-search", "fix-login-timeout", etc.
clean up finished workspaces
Once changes are merged, delete the workspace to keep things tidy.
don't fight the model
If you find yourself wanting to make changes across workspaces, it might be time to merge one and continue in a single workspace.