0
0
Gitdevops~3 mins

Listing worktrees in Git - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you want to work on different branches of a project at the same time without switching back and forth. Git worktrees let you have multiple working folders for the same repository. Listing worktrees shows you all these folders and their details.
When you want to see all the active worktrees linked to your repository.
When you need to check which branches are checked out in different worktrees.
When you want to clean up unused worktrees by identifying them first.
When you are collaborating and want to verify your local work environments.
When you want to confirm the paths of your worktrees before running commands on them.
Commands
This command shows all the worktrees connected to your current Git repository, including their paths and the branches checked out there.
Terminal
git worktree list
Expected OutputExpected
/home/user/myrepo 123abc4 [main] /home/user/myrepo-feature 456def7 [feature-branch]
This command lists worktrees in a machine-readable format, useful for scripts or detailed inspection.
Terminal
git worktree list --porcelain
Expected OutputExpected
worktree /home/user/myrepo HEAD 123abc4 branch refs/heads/main worktree /home/user/myrepo-feature HEAD 456def7 branch refs/heads/feature-branch
--porcelain - Outputs the list in a stable, parseable format for scripts.
Key Concept

If you remember nothing else from this pattern, remember: git worktree list shows all your active work folders and their branches so you can manage multiple workspaces easily.

Common Mistakes
Running git worktree list outside a Git repository folder.
Git cannot find the repository to list worktrees, so it shows an error.
Run git worktree list inside a folder that is part of a Git repository.
Confusing git worktree list output with git branch output.
git branch shows branches but not their worktree paths; git worktree list shows paths and branches.
Use git worktree list to see worktree paths and branches together.
Summary
Use git worktree list to see all active worktrees and their branches.
The --porcelain flag gives a script-friendly output format.
Listing worktrees helps manage multiple working folders for the same project.