How can you list the files that were changed in a specific commit?
Posted by NickCrt
Last Updated: June 10, 2024
To list the files that were changed in a specific commit using Git, you can use the git show command along with the commit hash. Here are a few ways to do this: 1. Using git show: You can run the following command, replacing COMMIT_HASH with the actual hash of the commit you are interested in:
git show --name-only COMMIT_HASH
This will display the details of the commit along with a list of the files that were changed. 2. Using git diff: If you want just the list of files without the commit message and other details, you can use:
git diff --name-only COMMIT_HASH^ COMMIT_HASH
Here, COMMIT_HASH^ refers to the parent of the specified commit. This command will give you only the names of the files that were changed in that commit. 3. Using git diff-tree: Another option is to use git diff-tree, which can also list the changes:
git diff-tree --no-commit-id --name-only -r COMMIT_HASH
The --no-commit-id option prevents the commit ID from being shown in the output, and -r ensures you get a recursive listing of changed files, even in subdirectories. Each of these commands will help you identify which files were altered in the specific commit you are interested in.
Related Content