GitWorktree.org logoGitWorktree.org

git worktree list: How to List Working Trees

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.

Try It: Inspecting Worktrees with git worktree list

Human-readable output, --porcelain for scripts, and filtering with pipes

The SetupA Busy Day

You've been multitasking on the acme project — a payment feature in progress, a hotfix shipped, and a teammate's auth PR under review. Three worktrees are open, but which branch is where? Let's use git worktree list to get the full picture.

~/code/
3 directories, 1 shared .git
├── acme/ [feature/payments]← you are here
├── .git/ full git database
├── src/
├── package.json
└── README.md
├── acme-hotfix/ [hotfix/checkout-crash]
├── .git → ../acme/.git (linked)
├── src/
├── package.json
└── README.md
└── acme-review/ [feature/auth-refactor]
├── .git → ../acme/.git (linked)
├── src/
├── package.json
└── README.md

acme/ has the real .git/ directory. acme-hotfix/, acme-review/ each have a tiny .git file that points back — no duplicate history, no wasted disk.

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/you/code/acme           d1e2f3a [feature/payments]
/home/you/code/acme-hotfix    7a8b9c0 [hotfix/checkout-crash]
/home/you/code/acme-review    b2c3d4e [feature/auth-refactor]

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/you/code/acme           d1e2f3a [feature/payments]
/home/you/code/acme-debug     e4f5a6b (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/you/code/acme
HEAD d1e2f3ad1e2f3ad1e2f3ad1e2f3ad1e2f3a4b5c6d
branch refs/heads/feature/payments

worktree /home/you/code/acme-hotfix
HEAD 7a8b9c07a8b9c07a8b9c07a8b9c07a8b9c0d1e2f3
branch refs/heads/hotfix/checkout-crash

worktree /home/you/code/acme-review
HEAD b2c3d4eb2c3d4eb2c3d4eb2c3d4eb2c3d4e5f6a7b
branch refs/heads/feature/auth-refactor

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-refactor' | 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)

Current Git releases 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/you/code/acme           d1e2f3a [feature/payments]
/home/you/code/acme-hotfix    7a8b9c0 [hotfix/checkout-crash]
/home/you/code/acme-usb       e4f5a6b [release/v2.3] 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.

Frequently Asked Questions

How do I list the working tree in the current directory?

Run git worktree list from any directory inside a Git repository. It shows all working trees linked to that repository, including the main one and any linked worktrees you have created. The first entry in the output is usually the main working tree (the original clone directory).

Does git worktree list show the main worktree too?

Yes. The output always includes the main worktree as the first entry. It is not possible to hide it from the list.

How do I find which worktree has a specific branch?

Use the porcelain format and grep for the branch:

Find a worktree by branch name
git worktree list --porcelain | grep -B1 'branch refs/heads/feat/auth' | head -1
# Output: worktree /home/user/project-feat-auth

Can I list worktrees from a bare repository?

Yes. git worktree list works in bare repositories. The main entry will show the bare repo path marked as (bare) instead of a branch name.

You Might Also Like