简体   繁体   English

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

[英]Git: How do I view file contents before a specific commit

I'm using我正在使用

git show commithash : filename git show commithash :文件名

to get the version of the file right before the change.在更改之前获取文件的版本。

How could I get the version right before that change was made, for comparation?我如何才能在进行更改之前获得版本以进行比较?

Assuming I'm understanding your question, you can go back as far as you want in your commit log to see whatever changes you want.假设我理解您的问题,您可以在提交日志中返回任意位置以查看您想要的任何更改。 And you can do it using the same command you're already using, but just change the commit hash to whichever commit you want to see.您可以使用您已经在使用的相同命令来执行此操作,但只需将提交哈希更改为您想要查看的任何提交。

Using this commit log as an example:以这个提交日志为例:

 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

You can use git show 123456789baf76cbbb9a2e7052f4aeb987654321 to show all changes for the Fix Expired listings ordering for when deactivated early commit.您可以使用git show 123456789baf76cbbb9a2e7052f4aeb987654321来显示Fix Expired listings ordering for when deactivated early提交Fix Expired listings ordering for when deactivated early所有更改。

Or you can use git show 9876543217a52dfd4387c6eb6f31431123456789 to show all changes for the Only sync user if relevant attributes have changed commit.或者,您可以使用git show 9876543217a52dfd4387c6eb6f31431123456789显示Only sync user if relevant attributes have changed提交,则Only sync user if relevant attributes have changed所有更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM