Git Worktree vs Stash
Both git worktree and git stash help you deal with in-progress work, but they solve different problems. Stash temporarily shelves changes so you can switch branches. Worktree gives you a second working directory so you never need to switch at all.
Comparison at a Glance
| Aspect | Git Stash | Git Worktree |
|---|---|---|
| What it does | Saves uncommitted changes to a stack and reverts the working tree to a clean state | Creates a separate directory with its own checked-out branch |
| Context switching | Sequential — stash, switch, work, switch back, pop | Parallel — both branches are available at the same time |
| Risk of conflicts | git stash pop can produce merge conflicts | No conflict risk — each worktree is independent |
| Build state | Destroyed on every switch — node_modules, build caches, etc. are shared | Preserved — each worktree has its own files on disk |
| Disk cost | None (stash entries are stored as commits in the object store) | Size of the checked-out files |
| Forgetting about it | Easy to forget stashed work; stash list grows silently | The directory is visible on disk; git worktree list shows all worktrees |
When to Use Git Stash
- You need to quickly switch branches for a few minutes and come right back.
- The context switch is short and your project has no expensive build step.
- You want to temporarily clean your working tree without committing half-done work.
- You are on a machine with limited disk space and cannot afford a second checkout.
When to Use Git Worktree
- You will be going back and forth between branches frequently throughout the day.
- Your project has a slow build or install step (e.g.,
npm install,cargo build) and switching branches would invalidate caches. - You want to run two dev servers side by side to compare behaviour.
- You have been burned by stash conflicts before and want to avoid them entirely.
How to Move Stashed Changes to a Worktree
If you have already stashed changes and now want to apply them in a separate worktree, here is how:
Step 1: Create a new worktree
# Create a worktree with a new branch based on where you stashed
git worktree add -b feature/resume-work ../resume-workStep 2: Apply the stash in the new worktree
cd ../resume-work
# List stashes to find the right one
git stash list
# stash@{0}: WIP on main: abc1234 Add header component
# stash@{1}: WIP on main: def5678 Update API client
# Apply the stash (keeps it in the stash list)
git stash apply stash@{0}
# Or pop it (removes it from the stash list)
git stash pop stash@{0}Because stashes are stored in the shared object store, they are accessible from any worktree. You do not need to do anything special to transfer them.
Alternative: Create a Branch Directly from a Stash
Git has a built-in command that creates a branch from a stash and applies the changes in one step. You can combine this with worktrees:
# Create branch from stash (in current directory)
git stash branch feature/from-stash stash@{0}
# Or create a worktree first, then apply:
git worktree add -b feature/from-stash ../from-stash
cd ../from-stash
git stash popRelated Pages
- What Is Git Worktree? — A beginner-friendly introduction
- Worktree vs Branch — How worktrees and branches work together
- Worktree vs Clone — Worktree vs a full separate repository copy