Git:如何在特定提交之前查看文件内容

时间:2015-11-18 14:04:58

标签: git

我正在使用

git show commithash filename

在更改之前获取文件的版本。

为了进行比较,我怎样才能在更改之前获得版本?

1 个答案:

答案 0 :(得分:0)

假设我理解您的问题,您可以在提交日志中尽可能地返回以查看您想要的任何更改。您可以使用您已经使用的相同命令来执行此操作,但只需将提交哈希更改为您想要查看的任何提交。

使用此提交日志作为示例:

 commit 123456789baf76cbbb9a2e7052f4aeb987654321
 Author: Ron Swanson <ron@swanson.com>
 Date:   Wed Nov 11 12:02:57 2015 -0500

     Fix Expired listings ordering for when deactivated early

 commit 9876543217a52dfd4387c6eb6f31431123456789
 Author: Leslie Knope <leslie@knope.com>
 Date:   Tue Nov 10 14:18:30 2015 -0500

     Only sync user if relevant attributes have changed

您可以使用git show 123456789baf76cbbb9a2e7052f4aeb987654321显示Fix Expired listings ordering for when deactivated early提交的所有更改。

或者您可以使用git show 9876543217a52dfd4387c6eb6f31431123456789来显示Only sync user if relevant attributes have changed提交的所有更改。

相关问题