How to list files that are changed in specific commit and get content of that files when I have sha number of commit ?
To find out which files changed in a given commit, use the git log --raw command.
In Git, we can use git show commit_id --name-only to list all the committed files that are going to push to the remote repository.
To see a list of commits with even more detail (including which files changed), run this command: git log --stat.
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:
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