I am looking for a simple git
command that provides a nicely formatted list of all files that were part of the commit given by a hash (SHA1), with no extraneous information.
I have tried:
git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d
Although it lists the files, it also includes unwanted diff information for each.
Is there another git
command that will provide just the list I want, so that I can avoid parsing it from the git show
output?
I use this to get list of modified files between two changesets:
OK, there are couple of ways to show all files in a particular commit...
To reduce the info 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...So you can do
git diff
followed by--name-only
, with two commit hashes after<sha0> <sha1>
, something like below:I also create the below image to show all steps to go through in these situation:
Using standard git diff command (also good for scripting):
If you want also the status of the changed files:
This works well with merge commits.
There is a simple trick to view as a file listing, just add
:
after the hash.You can then drill in,
If you hit a file you'll get the raw version of the file; which sometimes is what you want if you're only looking for a nice reference or key pieces of code (diffs can make everything a mess),
Only drawback of this method is that it doesn't easily show a tree of files.
There's also
git whatchanged
, which is more low level thangit log
It outputs the commit summary with a list of files beneath it with their modes and if there added(
A
), deleted(D
) or modified(M
);Would give something like:
I know this answer doesn't really match "with no extraneous information.", but I still think this list is more useful then just the filenames.
Display the log.
COMMIT can be blank ("") or the sha-1 or the sha-1 shortened.
This will list just the files, very useful for further processing.