在 Git 中跟踪单个文件的历史记录时如何查看完整提交?
我有一个 Git 存储库,其中有大约两年的历史。我其中有一个文件,我希望找到该文件的所有提交,并且对于每个提交:其中提交的所有其他文件。我们假设该文件名为 file.txt。我可以使用这个文件作为参数运行 gitk:
gitk file.txt
并且我确实得到了每个提交。但是,在 gitk 中浏览该树仅显示对 file.txt 所做的更改。我想看看该提交中还更改了哪些其他文件。我可以复制粘贴每个提交 SHA1 并显示它,但是有数百个与该文件相关的提交。
我注意到屏幕右下角的“评论”部分是空的(仅显示文本“评论”)。也许可以在那里显示文件列表?
I have a Git repository with about a two years of history in it. I have single file in it, for which I wish to find all the commits, and for each commit: all the other files that were committed in it. Let's assume this file is named file.txt. I can run gitk with this file as argument:
gitk file.txt
and I do get each commit. However, browsing that tree in gitk only shows changes done to file.txt. I'd like to see what other files were changed in that commit. I can copy paste each commit SHA1 and display it, but there are over hundred of commits related to this file.
I notice that "comments" section in bottom-right part of screen is empty (only shows text "Comments"). Maybe a list of files could be shown there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在命令行中,
会输出你想要的内容。
如果您必须在 gitk 中看到它,请使用 no 参数调用它,找到提交“touching path”file.txt,并且包含该文件的提交将以粗体显示。您可以使用“向上”和“向下”按钮来遍历它。
In the command line,
will output what you want.
If you must see it in gitk, invoke it with no arguments, find commit "touching path" file.txt, and the commit contains that file will be bold. And you can use the "up" and "down" buttons to traverse through it.
实际上,您可以在 gitk 中使用“--full-diff”功能,只是不能直接从命令行使用。
只需执行以下操作:
gitk file.txt
--full-diff
应该可以做到这一点。为什么 gitk 不允许您从命令行使用它对我来说是一个谜,因为它是一个非常有用的选项。
You can actually have '--full-diff' functionality in gitk, just not directly from the command line.
Just do the following:
gitk file.txt
--full-diff
That should do it. Why gitk doesn't allow you to use this from the command line is a mystery to me, for it is a very useful option.
邮件列表中的另一个解决方案可以追溯到 2008:
Another solution from the mailing list dated far back in 2008: