10

How to list files that are changed in specific commit and get content of that files when I have sha number of commit ?

Damir
  • 54,277
  • 94
  • 246
  • 365
  • The first part is a possible duplicate of http://stackoverflow.com/q/424071/223092 and the second part is a possible duplicate of http://stackoverflow.com/q/610208/223092 (probably among many others) – Mark Longair Oct 07 '11 at 09:46

1 Answers1

19

To list the files that were changed by a particular commit, you can do:

git show --name-only <commit>

If you want to suppress the log message from that output, you can add --pretty=format: to the options.

As for your second question, to see the content of a particular file from that commit, say with SHA1sum f414f31, you can do:

git show f414f31:Documentation/help.txt

... where the path Documentation/help.txt is relative to the top level of the working tree, regardless of whether you're in a subdirectory or not. If you need to extract a whole subdirectory, have a look at this question and answer:

Community
  • 1
  • 1
Mark Longair
  • 446,582
  • 72
  • 411
  • 327