Skip to content

Worktree

In one line

A worktree is an additional working directory linked to the same repository, letting you work on multiple branches simultaneously without cloning.

In simple words

git worktree lets you have multiple working directories for the same repository, each checked out to a different branch. This avoids the need to stash, clone, or switch branches when you need to work on two things at once.

For example, you can have your main worktree on the feature branch and a second worktree on main to fix a quick bug, without disturbing your feature work. Both worktrees share the same .git storage, so commits made in one are visible in the other.

Worktrees are useful for long-running tasks (tests, builds) on one branch while you work on another, or for keeping a stable checkout for reference while developing in another. Clean up with git worktree remove when done.

Example

bash
# Add a worktree on the main branch
git worktree add ../project-main main

# Now you have two working directories:
# ./project        (on feature)
# ../project-main  (on main)

# List worktrees
git worktree list

# Remove a worktree
git worktree remove ../project-main

worktree creates additional working directories for the same repo.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary