How Do I List All the Files in a Commit?

Better Stack Team
Updated on June 24, 2024

To list all the files in a specific commit in Git, you can use the git diff-tree command. Here's how you can do it:

git diff-tree --no-commit-id --name-only -r <commit-hash>

Replace <commit-hash> with the hash of the commit you want to list the files for.

This command will list all the files that were affected by the specified commit. Each file will be listed on a separate line.

Alternatively, if you want to see the changes introduced by a specific commit, including the list of files and the modifications made to each file, you can use:

git show --name-only <commit-hash>

This command will display the commit message, followed by the list of files and the changes made to each file in the specified commit.


  • Replace <commit-hash> with the hash of the commit you're interested in. You can find the commit hash using git log.
  • The git diff-tree command is useful for listing files without showing the actual changes, while git show displays both the files and the changes made in the commit.
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github