简体   繁体   English

文档在哪里解释了为什么“git log” output 根据签出的分支而有所不同?

[英]Where do docs explain why "git log" output differs based on checked-out branch?

The output from git log is different based on what branch I currently have checked-out.来自git log的 output 根据我当前签出的分支而有所不同。 Where in the git documentation does it explain this behavior? git 文档在哪里解释了这种行为?

I looked at git log --help and git rev-list --help but don't see anything explaining the that git log is context-sensitive based on which branch I have checked-out.我查看了git log --helpgit rev-list --help但没有看到任何解释git log基于我签出的分支是上下文相关的。

EDIT:编辑:
I had read the following section that @max and @James mentioned, and it's clear what happens when one of the commits is omitted and .. is specified.我已经阅读了@max 和@James 提到的以下部分,并且很清楚当省略其中一个提交并指定..时会发生什么。 But it's ambiguous what happens when both commits are omitted.但是当两个提交都被省略时会发生什么是模棱两可的。 And it's also ambiguous when one commit is omitted and the .. is omitted:当一个提交被省略并且..被省略时,它也是模棱两可的:

<since>..<until> <从>..<直到>

Show only commits between the named two commits.仅显示指定的两个提交之间的提交。 When either <since> or <until> is omitted, it defaults to HEAD, ie the tip of the current branch.当 <since> 或 <until> 被省略时,它默认为 HEAD,即当前分支的尖端。

So, for example, the following would be equivalent:因此,例如,以下内容是等价的:
git log master.. is equivalent to: git log master..等价于:
git log master..HEAD

git log..master is equivalent to: git log..master等价于:
git log HEAD..master

But, if both <since> and <until> are omitted, then what?但是,如果 <since> 和 <until>被省略了,那又如何呢?
git log is NOT equivalent to: git log等同于:
git log HEAD..HEAD

So what is git log equivalent to in the <since>..<until> format?那么,<since>..<until> 格式中的git log等价于什么?

And if only one commit is listed, but not .. , then what?如果只列出了一个提交,但没有列出.. ,那会怎样?
git log foo equivalent to: git log foo等价于:
git log foo..HEAD or git log foo..HEAD
git log HEAD..foo ? git log HEAD..foo

One of the first sections of git-log man page :git-log 手册页的第一部分之一:

<since>..<until> <从>..<直到>

Show only commits between the named two commits.仅显示指定的两个提交之间的提交。 When either <since> or <until> is omitted, it defaults to HEAD, ie the tip of the current branch.当 <since> 或 <until> 被省略时,它默认为 HEAD,即当前分支的尖端。

git log needs a point (or points) to start from, so when no revision is provided, it defaults to HEAD , which points to current branch. git log需要一个(或多个)点开始,所以当没有提供修订时,它默认为HEAD ,它指向当前分支。

Git log has an implied argument HEAD so when you do Git 日志有一个隐含的参数 HEAD 所以当你这样做时

git log git日志

you are actually doing你实际上在做

git log HEAD git 日志头

which means you will get the log from the tip of the current branch这意味着您将从当前分支的尖端获取日志

From Git Log Manual for since..until optionsGit 日志手册中获取 since..until 选项

Show only commits between the named two commits.仅显示指定的两个提交之间的提交。 When either or is >omitted, it defaults to HEAD , ie the tip of the current branch.当 或 被 > 省略时,它默认为 HEAD ,即当前分支的尖端。 For a more complete >list of ways to spell and, see gitrevisions(7).如需更完整的 > 拼写方式列表,请参阅 gitrevisions(7)。

As per updated question the following should explain all the situations you stated根据更新的问题,以下应解释您所说的所有情况

From Git RevisionsGit 修订

For example, origin.. is a shorthand for origin..HEAD and asks "What did I do since I >forked from the origin branch?"例如,origin.. 是 origin..HEAD 的简写,并询问“自从我 > 从 origin 分支分叉后我做了什么?” Similarly, ..origin is a shorthand for HEAD..origin and >asks "What did the origin do since I forked from them?"类似地,..origin 是 HEAD..origin 的简写,并且 > 询问“自从我从他们那里分叉后,origin 做了什么?” Note that.. would mean >HEAD..HEAD which is an empty range that is both reachable and unreachable from HEAD.请注意,.. 意味着 >HEAD..HEAD 是一个空范围,可以从 HEAD 到达和无法到达。

If.. is omitted then it is just如果.. 被省略,那么它只是

git log <rev>

which include commits that are reachable from (ie ancestors of) rev.其中包括可从 rev (即祖先)访问的提交。 This is explained in git-rev-list who's options are applicable to git-log as stated in the manual.如手册中所述,这在git-rev-list谁的选项适用于 git-log 中进行了解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 git从已签出的存储到分支 - git from checked-out stash to branch 为什么Git允许推送到添加的工作树中的已签出分支? 我应该如何恢复? - Why does Git allow pushing to a checked-out branch in an added worktree? How shall I recover? 从检出的 Git 分支中找到“父”分支的可靠方法 - Reliable way of finding 'parent' branch from a checked-out Git branch 显示所有最近的 git 提交,无论它们是否属于本地签出分支 - Show all recent git commits, whether they belong to a locally checked-out branch or not 如何使签出的分支成为主分支 - How to make checked-out branch to become master 检查是否将提取分支并允许将其检出 - Check whether a branch will be fetched and allowed to be checked-out 存储在refs / head之外的ref是否可以被视为分支并签出并作为普通分支进行处理? - Can a ref stored outside refs/heads be considered a branch and checked-out and worked-on as a normal branch? git在哪里存储最后签出的分支? - Where does git store the last checked out branch? 使用git进行Web部署-如何仅在检出的实时站点中拥有大型二进制文件,而不是git repo中的blob - Web deployment with git - how to have large binaries only in checked-out live site, and not as blobs in git repo 未知的git分支已签出 - Unknown git branch checked out
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM