【发布时间】:2021-03-10 19:14:18
【问题描述】:
【问题讨论】:
-
git show <hash>
标签: bash git command-line command
【问题讨论】:
git show <hash>
标签: bash git command-line command
您可以使用git-log 显示影响给定文件的提交SHA,并使用@joanis 建议的git-show 显示这些更改:
git log <path>
git show <hash> <path>
您也可以使用git-diff 显示此输出。如果您希望通过多次提交而不是单个提交来查看文件的更改,这可能会更有帮助:
# changes made by the commit
git diff <hash>~ <hash> <path>
# changes made by the commit and the previous one
git diff <hash>~2 <hash> <path>
请参阅this question 了解有关引用先前提交的更多信息
【讨论】:
git show 基本上是git log -1 --patch 的别名,单个提交的最短版本是git log -1 -m -p -- path,-m 甚至可以在合并时获得补丁。