【问题标题】:How do I print a file from another branch with git?如何使用 git 从另一个分支打印文件?
【发布时间】:2021-02-02 14:40:59
【问题描述】:

我知道有git cat-file,但它需要sha

我想要做的是类似于git cat-file mybranch -- path/to/myfile.txt 的东西,它会完成与

相同的事情
git checkout mybranch && cat path/to/myfile.txt

除了它实际上不会签出分支。我该怎么做?

【问题讨论】:

  • 你确定它只接受散列而不接受任何形式的修订吗?
  • @MadPhysicist 不,我不是,但我找不到告诉我另一种方法的文档,看来我可能错过了。
  • 大多数 git 程序都会对其输入进行规范化。至少值得尝试看看它是否有效。

标签: git sh


【解决方案1】:

您可以通过多种方式做到这一点:

git cat-file blob mybranch:path/to/myfile.txt

git show mybranch:path/to/myfile.txt

【讨论】:

    猜你喜欢
    • 2021-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-12
    • 2012-11-22
    • 1970-01-01
    • 2018-11-27
    相关资源
    最近更新 更多