A stash parks your changes and gives you a clean tree. A worktree gives you a second directory with a different branch checked out, and keeps your first one as it is.
Use a stash for minutes. Use a worktree for hours.
Stash your changes
Section titled “Stash your changes”Press s in the files panel to stash everything. Press S for the variants.
| Variant | What it takes |
|---|---|
| stash all changes | Every tracked change |
| stash including untracked | Tracked changes, and new files |
| stash, keep index | Everything, and the index stays as it was |
| stash staged only | The index only |
Use a stash again
Section titled “Use a stash again”Press 5 for the stash panel.
| Key | Action |
|---|---|
space |
Apply the stash, and keep it in the list |
g |
Apply the stash, and remove it from the list |
d |
Delete the stash |
r |
Rename the stash |
W |
Compare against the marked reference |
CAUTION: d deletes the stash. Apply it first if you want to read it.
Applying a stash can conflict, like a merge. Read Conflicts for the keys that finish it.
Worktrees
Section titled “Worktrees”A worktree is a second directory that shares one repository. Both directories see the same commits, the same remotes, and the same stashes. Each has its own branch and its own working tree.
Press 2, then ] for the worktrees tab.
| Key | Action |
|---|---|
n |
Add a worktree |
space |
Switch to the worktree under the cursor |
d |
Remove the worktree |
o |
Open the worktree in your editor |
space re-roots stage into that directory. The panels then show the branch and
the changes of the worktree you switched to.
Set worktreeDefaultPath in the configuration to choose where a new worktree
goes. A relative path is resolved against the root of the repository, and ~
means your home directory.
Submodules
Section titled “Submodules”Press 2, then ] twice for the submodules tab.
| Key | Action |
|---|---|
space |
Enter the submodule |
i |
Initialize the submodule |
u |
Update the submodule |
n |
Add a submodule |
e |
Change the URL |
d |
Remove the submodule |
b |
Run one command on every submodule |
space re-roots stage into the submodule, the same way a worktree switch does.
Press esc to come back out to the repository above.