如何`git log`来自另一个分支的树状结构?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18830659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:58:13  来源:igfitidea点击:

How to `git log` a tree-ish from another branch?

gitgit-log

提问by ulidtko

Let's say I have a Git repo with branch Aand branch B.
Branch Bis currently checked out (i.e. .git/HEADcontains refs/heads/B).
Now, without checking out branch A, how to view the history (log) of path/filein branch A?

假设我有一个带有 branchA和 branch的 Git 存储库B
分支B当前已签出(即.git/HEADcontains refs/heads/B)。
现在,没有检查出的分支A,如何看待历史(日志)path/file的分支A

Following git help rev-parse, I've attempted to use git log A:path/file, but that doesn't seem to work (outputs nothing). Why?

以下git help rev-parse,我尝试使用git log A:path/file,但这似乎不起作用(不输出任何内容)。为什么?

回答by patrickvacek

Try this (without the angle brackets):

试试这个(没有尖括号):

git log <branch> -- <path/to/file>

git log <branch> -- <path/to/file>