I regularly use the following command to list files changed between two commits:
git diff --name-only SHA1 SHA2
It gives a list of files somewhat like this:
/src/example/file1 /src/example/file2 /src/example/file3
There is almost no end to how useful this is.
I'd really like to be able also to show alongside each file a brief reference to the change status, indicating whether a file was added, modified or deleted.
Here's an example to demonstrate the concept:
git diff --name-only --and-how-me-the-change-status SHA1 SHA2
A /src/example/file1 M /src/example/file2 D /src/example/file3
The change status (A, M, D) is shown as an example only, I don't mind what this is so long as it is unambiguous.
I'm aware that I can use the --diff-filter
option to list only added files, or only modified files or only deleted files. Using this option means I have to run three commands to get three lists of filenames. This is nice but could be nicer.
Is there a single command I can run to give me the above example output?
To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.
OK, there are a couple of ways to show all files in a particular commit... To reduce the information and show only names of the files which committed, you simply can add --name-only or --name-status flag... These flags just show you the file names which are different from previous commits as you want...
"git diff" always show the difference between two commits (or commit and working directory, etc.).
Use --name-status
, it's the same as --name-only
plus the status of changed files:
git diff --name-status SHA1 SHA2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With