【问题标题】:How to list files in specific revision in `git`?如何在`git`中列出特定修订版中的文件?
【发布时间】:2011-03-07 02:26:39
【问题描述】:

我想知道 git 存储库中特定版本的文件列表。 我该怎么做?

【问题讨论】:

    标签: git list file revision


    【解决方案1】:
    git ls-tree -r --name-only $REV
    

    例如

    git ls-tree -r --name-only a27689bf7f46dc0735c5b3b6076010c87224063e
    

    【讨论】:

      【解决方案2】:

      查看 dannyp 的回答。

       git ls-tree -r --name-only $REV
      

      【讨论】:

      • 这是错误的。 ls-files --with-tree 将生成索引中或指定树状结构中的所有路径名的列表。示例:假设当前未跟踪 newfile。 touch newfile && git add newfile && git commit -mnewfile && git ls-tree --with-tree=HEAD~ 将显示newfile,即使它不在 HEAD~ 中。 ls-files 真的是关于索引和/或工作树。使用ls-tree 检查树形对象(树、提交、标签)的内容。
      • 呃,原来的提问者已经批准了这个答案。好吧,让不良信息流连忘返是没有意义的。
      • @Chris 也许我想要的是:)
      • 我建议切换已批准的答案。干杯!
      猜你喜欢
      • 1970-01-01
      • 2012-07-14
      • 2010-10-11
      • 1970-01-01
      • 2023-01-13
      • 1970-01-01
      • 2011-08-28
      相关资源
      最近更新 更多