tree displays directory structures as a recursive tree.
It is useful for inspecting a project layout, documenting repository structure, and sharing a concise overview of files and folders.
The tool is installed through Homebrew and declared in the project Brewfile.
It is part of the curated Homebrew environment; see Homebrew setup to install everything at once.
Install tree directly:
brew install treeVerify the installation:
tree --version
brew list --formula | grep -x treeDisplay the current directory structure:
treeLimit the displayed depth:
tree -L 2Include hidden files:
tree -aDisplay directories only:
tree -dProject directories often contain generated or dependency folders that make the output difficult to read.
Exclude common heavy directories:
tree -L 3 -I '.git|vendor|node_modules'For a Symfony project:
tree -L 3 -I '.git|vendor|node_modules|var'Display file sizes:
tree -hDisplay full relative paths:
tree -fExport the structure to a text file:
tree -L 3 -I '.git|vendor|node_modules' > project-tree.txtThe generated file should only be committed when it provides lasting documentation value.
tree is useful for:
- documenting or reviewing a repository layout;
- sharing an architecture overview;
- comparing folder structures before and after a change.
tree is read-only.
It displays filesystem contents and does not modify files or directories.
Be careful before sharing its output publicly, as file and directory names can expose sensitive paths and filenames.
Display the available options:
tree --helpConfirm the executable path:
command -v treeIf the output is too large, reduce the depth or exclude additional directories:
tree -L 2 -I '.git|vendor|node_modules|var|cache'Remove tree with Homebrew:
brew uninstall treeThen remove its entry from profiles/full/Brewfile.