GitWorktree.org logoGitWorktree.org

git worktree list: View All Worktrees

The git worktree list command displays every worktree linked to your repository, including the main worktree. It is the quickest way to see which branches are checked out, where the working directories live on disk, and which commit each worktree's HEAD points to.

Basic Usage

git worktree list

Run this command from any worktree in the repository. It will display all linked worktrees regardless of which one you are currently in:

Example output
$ git worktree list
/home/user/project          abc1234 [main]
/home/user/project-feature  def5678 [feature/auth]
/home/user/project-hotfix   789abcd [hotfix/login-bug]

Output Format

Each line of output contains three pieces of information:

  1. Path— the absolute path to the worktree directory on disk.
  2. HEAD commit— the abbreviated SHA-1 of the commit currently checked out.
  3. Branch— the branch name shown in square brackets. If the worktree is in detached HEAD state, you will see (detached HEAD) instead of a branch name.
Detached HEAD example
$ git worktree list
/home/user/project       abc1234 [main]
/home/user/project-tag   fedcba9 (detached HEAD)

Locked worktrees are annotated with locked at the end of the line, which is useful for identifying worktrees on removable drives or network shares.

Porcelain Format (--porcelain)

The default human-readable output is convenient for quick checks, but it is not ideal for scripts. Use --porcelain to get a machine-parseable format:

Porcelain output
$ git worktree list --porcelain
worktree /home/user/project
HEAD abc1234abc1234abc1234abc1234abc1234abc1234
branch refs/heads/main

worktree /home/user/project-feature
HEAD def5678def5678def5678def5678def5678def5678
branch refs/heads/feature/auth

In porcelain mode, each worktree is a block of key-value lines separated by a blank line. The HEAD is the full 40-character SHA-1, and the branch is given as a full ref path. If the worktree is in detached HEAD state, the branch line is replaced with detached.

Filtering & Scripting Examples

Combining git worktree list --porcelain with standard shell tools makes it easy to extract exactly the information you need:

Scripting with porcelain output
# List only the worktree paths
git worktree list --porcelain | grep '^worktree ' | cut -d' ' -f2

# Count the number of active worktrees
git worktree list --porcelain | grep -c '^worktree '

# Find which worktree has a specific branch checked out
git worktree list --porcelain | grep -B1 'branch refs/heads/feature/auth' | head -1
Shell helper: jump to a worktree by branch
# Shell function to jump to a worktree by branch name
wt() {
  local dir
  dir=$(git worktree list --porcelain \
    | awk -v branch="refs/heads/$1" \
      '/^worktree /{dir=$2} /^branch /{if($2==branch) print dir}')
  if [ -n "$dir" ]; then
    cd "$dir" || return
  else
    echo "No worktree found for branch '$1'"
  fi
}

Verbose Output (-v)

Git 2.36 and later support the -v flag, which provides additional details such as the lock reason for locked worktrees and prunable status for stale entries:

Verbose output with lock reason
$ git worktree list -v
/home/user/project          abc1234 [main]
/home/user/project-feature  def5678 [feature/auth]
/home/user/usb-worktree     789abcd [release/v2] locked (reason: on USB drive)

This is especially useful when you have worktrees on removable drives or network shares and want to see why they are locked at a glance.

Next Steps

If git worktree list shows worktrees whose directories no longer exist on disk, those entries are stale and should be cleaned up. See the git worktree prune tutorial to learn how to remove them.

For a complete overview of git worktree commands, return to the Tutorial index.