问题:
I have a Git repository and I'd like to see how some files looked a few months ago. 我有一个Git存储库,我想看看几个月前某些文件的外观。 I found the revision at that date, and it's 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8
. 我在那个日期找到了修订版本,它是27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8
。 I need to see what did one file looks like and also save that to a file. 我需要查看一个文件的外观,并将其保存到文件中。
I managed to see the file using gitk
, but it doesn't have an option to save it. 我设法使用gitk
来查看文件,但是它没有保存文件的选项。 I tried with command-line tools, the closest I got was: 我尝试使用命令行工具,但最接近的是:
git-show 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8 my_file.txt
However, this command shows a diff and not the file contents. 但是,此命令显示差异而不显示文件内容。 I know I can later use something like PAGER=cat
and redirect output to a file, but I don't know how to get to the actual file content. 我知道以后可以使用PAGER=cat
类的东西并将输出重定向到文件,但是我不知道如何获取实际的文件内容。
Basically, I'm looking for something like svn cat . 基本上,我正在寻找svn cat之类的东西。
解决方案:
参考一: https://stackoom.com/question/2Yk4/如何从Git中的特定修订版本检索单个文件参考二: https://oldbug.net/q/2Yk4/How-to-retrieve-a-single-file-from-a-specific-revision-in-Git
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/3651961