Forrest logo
back to the git tool

git-rev-parse:tldr:871f2

git-rev-parse: Get the absolute path to the root directory.
$ git rev-parse --show-toplevel
try on your machine

The command git rev-parse --show-toplevel is used to display the absolute path of the top-level directory in a Git repository.

In a Git repository, the top-level directory is the root directory of the repository. It is the parent directory of all the files and subdirectories in the repository.

By running git rev-parse --show-toplevel, Git will output the absolute path of the top-level directory. This can be useful when you need to reference the root directory in other commands or scripts, as it provides a reliable way to determine the location of the repository.

For example, if you are in a Git repository located at /home/user/project/, running git rev-parse --show-toplevel will output the path /home/user/project/.

Note that if you run this command outside of a Git repository, it will return an error message since there is no top-level directory to be found.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool