简体   繁体   English

显示所有最近的 git 提交,无论它们是否属于本地签出分支

[英]Show all recent git commits, whether they belong to a locally checked-out branch or not

Let's say I have a git repo with various branches.假设我有一个带有各种分支的 git 存储库。 If I do如果我做

git log --oneline | head

I will see a list of the latest commits on the current branch.我将看到当前分支上最新提交的列表。 If I do如果我做

git log --branches=* --oneline | head

I will see a list of the latest commits on any locally checked-out branch.我将在任何本地签出的分支上看到最新提交的列表。 But what should I do to see a list of all the latest commits, whether or not they are on any locally checked-out branch?但是我应该怎么做才能看到所有最新提交的列表,无论它们是否在任何本地签出的分支上? As far as I can tell, this isn't a matter of the commits only existing on the remote, because I can do eg据我所知,这与仅存在于远程的提交无关,因为我可以这样做

git checkout <hash>

and see the contents of the commit;并查看提交的内容; it's just that if I then check out master again, I cannot get it to show up in git log .只是如果我再次检查master ,我无法让它显示在git log中。

By default, git log starts with the currently checked out commit (called HEAD) and works back through its history from there.默认情况下, git log从当前签出的提交(称为 HEAD)开始,并从那里返回其历史记录。

I believe you want --all .我相信你想要--all

Pretend as if all the refs in refs/, along with HEAD, are listed on the command line as.假装 refs/ 中的所有 ref 以及 HEAD 都列在命令行中。

So if you have branch1, branch2, origin/branch1, origin/branch2, tag1, tag2 git log --all is equivalent to git log branch1 branch2 origin/branch1 origin/branch2 tag1 tag2 HEAD .因此,如果您有 branch1、branch2、origin/branch1、origin/branch2、tag1、 git log --all等效于git log branch1 branch2 origin/branch1 origin/branch2 tag1 tag2 HEAD

If all you want to see is the commits in chronological order, that's enough.如果您只想看到按时间顺序排列的提交,那就足够了。 If you'd like to see how they relate add --graph to show their connections and --decorate to show references (tags and branches).如果您想了解它们之间的关系,请添加--graph以显示它们的连接和--decorate以显示参考(标签和分支)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM