【问题标题】:View git history for folder查看文件夹的 git 历史记录
【发布时间】:2012-08-10 14:39:57
【问题描述】:

如何查看文件夹中所有文件的 git 日志历史记录?

我找到了几篇关于如何显示特定文件的日志的帖子,但没有找到特定文件夹的帖子。

【问题讨论】:

    标签: git


    【解决方案1】:

    您可以使用foldernamefoldername/*。无论哪种方式都应该有效。

    git log -- path/to/folder
    git log -- path/to/folder/*
    

    此方法不会跟踪重命名文件的历史记录。

    请注意-- 也是可选的。 (来自 git log 手册)

    [--] <path>...
    
               Show only commits that are enough to explain how the files that match the specified paths came to be. See History Simplification below for
               details and other simplification modes.
    
               Paths may need to be prefixed with -- to separate them from options or the revision range, when confusion arises.
    

    【讨论】:

    • 并删除path/to/folder下的目录?他们会出现吗?
    • @Zarathustra:是的。使用第一个命令(不带*),它们肯定会出现
    • 还有兴趣:添加 -p。除了提交 ID 之外,您还将获得很好的差异。
    • 我猜这在 2016 年之后发生了变化,因为目前这两个命令只会显示提交日志:提交哈希、作者、日期和提交消息 - 没有别的。
    • @JuhaUntinen 它还应该显示什么? git log 只显示提交信息。如果您想查看文件更改,请提供上一条评论中提到的-p 标志
    【解决方案2】:

    如果要使用图形工具,比如gitk,也是一样的:

    gitk -- path/to/folder
    

    【讨论】:

    • 我一直在使用 sourcetree 并且喜欢它。想知道 gitk 在 UI 方面与 sourcetree 相比如何。
    • gitk 有一个非常实用的用户界面,但其他方面还不错。如果您喜欢漂亮的 UI,那么您还可以考虑 Sublime Text 团队的 Merge (WIN/MAC/*NIX) 和 Fork (WIN/MAC)。
    猜你喜欢
    • 2011-04-20
    • 2010-12-19
    • 2018-11-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 2013-06-17
    • 2010-09-21
    相关资源
    最近更新 更多