[Git] Find the root directory of the working tree

Created on November 30, 2026

You can run git rev-parse --show-toplevel from any directory inside a Git working tree to print the absolute path to its root.

git rev-parse --show-toplevel

For example, running the command from /home/tom/project/docs prints /home/tom/project if that is the root of the working tree.

Git