Forrest logo
back to the git tool

git-ls-tree:tldr:788e1

git-ls-tree: List only the filenames of the tree on a commit.
$ git ls-tree --name-only ${commit_hash}
try on your machine

The command git ls-tree --name-only ${commit_hash} is used to list the files and directories in a specific commit in your Git repository.

Here is a breakdown of the command and its components:

  • git ls-tree: This Git command is used to list a tree object in the repository. In this case, it will list the files and directories in a specific commit.
  • --name-only: This option is used to specify that we only want to output the names of the files and directories in the commit. It eliminates any additional information, such as the file mode, object type, and commit hash.
  • ${commit_hash}: This is a placeholder for the actual commit hash you want to list the files and directories from. The commit hash is a unique identifier for a specific commit in your Git repository. You need to replace ${commit_hash} with the actual commit hash you want to work with.

By running this command, Git will output a list of files and directories in the specified commit, displaying only their names.

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