How to get files and content by SHA of commit

如何列出在特定提交中更改的文件,并在我提交了数量的提交时获取该文件的内容?


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:

  • What's the best way to extract a tree from a git repository?
  • 链接地址: http://www.djcxy.com/p/26648.html

    上一篇: 提交钩子:获取已更改文件的列表

    下一篇: 如何通过提交SHA获取文件和内容