最现成的答案是
git show-branch
你可以做更多的控制是使用git log附件git rev-list:
git log --left-right --graph --cherry-pick \
--oneline branchname...remote/branchname
这是我的首选方法,会产生类似
> | fff6bda remote fix
< | c8903ee local fix
< | 724373c Merge branch 'bla' into bla
|\ \
| < | 2faf547 details
| < | abbdc47 ....
|/ /
< | befc181 some tagged commit
包括--decorate,你会得到接近gitk、git-gui和gitweb的东西:
> | fff6bda remote fix
< | c8903ee local fix
< | 724373c (tag_4) Merge branch 'bla' into bla
|\ \
| < | 2faf547 details
| < | abbdc47 ....
|/ /
< | befc181 (tag_3) some tagged commit
专业提示 1:使用 'git config alias.lr log --long-option1 --long-option2' 方便使用
专业提示 2:使用“git config color.ui auto”来立即缓解眼部问题
如果您想要 所有 个本地头(在所有本地分支上)与 所有 个远程提交(在同上分支上):
git log --decorate --pretty=oneline --all --not --glob=refs/remotes --no-walk
不要走不通,以获取所有单独的修订。在这种情况下,我更喜欢使用前面显示的开关(--graph --left-right)
合并
如果你想清楚地看到合并,包括 --boundary
各种高级查询:
过滤结果
Git log 和 rev-list 支持一整套狡猾的过滤能力,请参阅手册页
--after '2001-01-01'
--until 'last week'
--author 'martin'
-E -i --grep='fixes #[0123456789]+'
-S 'new_debug_function'
还有很多很多其他的。这应该为您提供足够的杠杆作用,几乎可以零努力地获得您想要的信息
本地存储了什么?
什么驻留在存储中,但不在远程(请注意,无法引用远程分支上的存储,因为存储驻留在 reflogs 中,并且 reflogs(即使对于远程分支)总是反映本地历史记录[1]):
git log $(git rev-list -g stash) --not --glob=refs/remotes
所有(其他)无法访问的提交...
注意事项
脚本
出于脚本目的,将git log 的使用替换为git rev-list,您将只获得哈希值(以及更多脚本文件的健壮性)
[1] 另请参阅我之前关于如何在存储库之间转移存储的答案: