66

I have commit, abc, and I want to list files that were modified for the commit.

What is the git command which will list modified files for that commit?

random
  • 9,774
  • 10
  • 66
  • 83
Alpha
  • 13,320
  • 27
  • 96
  • 163

3 Answers3

97

For filenames only:

git show --name-only abc

To see a summary of what happened to them:

git show --name-status abc
Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
  • 6
    for last commit, `git show --name-only` – Raza Ahmed Nov 11 '15 at 13:45
  • 9
    To really get _only_ the names, also use `--pretty=format:`, which makes it omit the commit metadata. Then you can use it to, for example, re-edit all the files from a previous commit: `vim -O $(git show --name-only --pretty=format: HEAD)`. Or pipe the response through `xargs` and use your imagination. – Rob Kennedy Jul 17 '17 at 20:17
  • 1
    handy review onleliner - open these file in sublime: `git show --name-only --format=oneline | tail -n+2 | xargs subl` – ptim Jul 20 '17 at 04:16
35

You can see the files changed in a particular commit as follows

git show --stat <commit-hash>

Alternatively you can also view the patch introduced with each commit using the -p flag

git log -p <commit-hash>

BTW git show takes the same formatting arguments as git diff-tree, here's the documentation for diff-tree.

shantanusinghal
  • 714
  • 1
  • 8
  • 17
2

For anyone who'd like to have an output summary like this for particular commit

enter image description here

Step

  1. Open your ~/.gitconfig file

  2. add this script under [alias]:

    swt = show --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --numstat

  3. Save ~/.gitconfig file

  4. Simply run git swt <commit-hash>

Alphapico
  • 2,893
  • 2
  • 30
  • 29