【问题标题】:How can I show the history that changed files at specify hash using git command?如何使用 git 命令显示在指定哈希处更改文件的历史记录?
【发布时间】:2021-03-10 19:14:18
【问题描述】:

我可以使用 Github 或 Git 工具(SourceTree、SmartGit)显示在指定哈希处更改文件的历史记录。

如何使用 Git 命令显示在指定哈希处更改文件的历史记录?

【问题讨论】:

  • git show <hash>

标签: bash git command-line command


【解决方案1】:

您可以使用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 甚至可以在合并时获得补丁。
猜你喜欢
  • 2019-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-06
  • 1970-01-01
相关资源
最近更新 更多