CodeBlanks Logo Icon CodeBlanks

worktree list

Learn the tree list with git worktree list.

git worktree list

git worktree list lists all working trees connected to a Git repository. Its output shows each worktree's directory path, associated commit, and active branch when available. This command helps you see which branch is checked out in each directory when using multiple worktrees.

git worktree list

/home/user/project   abc1234 [main]
/home/user/feature   def5678 [feature]

Interpreting the List Output

Each line represents a worktree, and the full directory path appears at the beginning of the line. The short identifier after the path shows the commit associated with that worktree. Branch information appears inside square brackets; a detached worktree may show a different reference instead of a branch.

/projects/app  a1b2c3d [main]
/projects/test d4e5f6a [testing]

In this output, two separate directories are associated with two different branches.

Practice Display the Worktree List

Create a command variable representing a Git command. This command should list all working trees connected to the repository. Then print the variable's value.

Starter code

terminal
// Çalışma ağaçlarını listeleyen komutu yaz
const command = "";

// Komutu ekrana yazdır

Sample solution

terminal
const command = "git worktree list";
console.log(command);

Expected output

git worktree list

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does the information inside square brackets in a worktree list show?

  • The remote server address
  • The full message of the latest commit
  • The number of files in the working directory
  • The branch checked out in the worktree Correct answer

Explanation: Entries such as <code>[main]</code> or <code>[feature]</code> in the list indicate the branch checked out in that worktree.

2 List the Working Trees

Question
git worktree ____
Answer
git worktree list

Explanation: The <code>list</code> option displays the working trees connected to the repository and their paths.

3 Worktree List Output

Term Meaning
Dizin yolu Worktree location
Commit kimliği Short ID of the associated commit
[main] Name of the active branch
Her satır Represents one worktree

All lessons in Advanced