How to List All the Files in a Commit
In this tutorial, we are going to show two ways of formatted file list.
Using git diff-tree is considered as a preferred way of listing files in a commit as it is a plumbing command. It is used to compare the content and mode of blobs found via two tree objects.
git diff-tree --no-commit-id --name-only -r bd61ad98
The following way of listing files is less preferred for scripts as it is a porcelain command:
git show --pretty="" --name-only bd61ad98
- --no-commit-id - suppresses ID output of the commit.
- --pretty - defines an empty format string for avoiding the cruft at the beginning.
- --name-only - displays only the file names that were affected (Thanks Hank). Use --name-status argument instead to see what happened to each file (Added, Modified, Deleted)
- -r - recurses into sub-trees
If you want to list all changed files between two commits use the git diff command:
git diff --name-only START_COMMIT..END_COMMIT
You can also use --name-status to include the added, modified or deleted change next to each file:
git diff --name-status START_COMMIT..END_COMMIT
Plumbing and Porcelain Commands
Since Git was initially a toolkit rather than a user-friendly Version Control System, there are a number of subcommands that do low-level work. These commands are called “plumbing” commands, while user-friendly commands are called “porcelain”.
The lower-level plumbing commands give access to the inner workings of Git helping demonstrate the actions of Git. Many of these commands aren’t used manually on the command line but are used as building blocks for new tools and custom scripts.
The git dif Command
The git diff is used to compare changes committed in Git. With the help of git diff, you can take two input data sets and output the modifications between them. It can display changes between the working tree and the index (or a tree), between the index and a tree, between two trees, two blob objects, or between two files on disk.