TLDR;使用 git show-tree 或 git lg 别名(我的首选)。
在树视图中显示所有分支(包括远程分支):
使用git show-tree:
在 Ubuntu 上测试:
# Install it
sudo apt install git-extras
# Run it:
git-show-tree
# OR (same thing)
git show-tree
这会产生类似于此处 2 个最受好评的答案的效果。
来源:http://manpages.ubuntu.com/manpages/bionic/man1/git-show-tree.1.html
示例:
man git show-tree 显示以下示例:
示例
将所有分支的提交历史日志输出为树形视图:
* 4b57684 (HEAD, develop) Merge branch upstream master.
|\
| * 515e94a Merge pull request #128 from nickl-/git-extras-html-hyperlinks
| |\
| | * 815db8b (nickl/git-extras-html-hyperlinks, git-extras-html-hyperlinks) help ronn make hyperlinks.
| * | 7398d10 (nickl/develop) Fix #127 git-ignore won´t add duplicates.
| |/
| | * ab72c1e (refs/stash) WIP on develop: 5e943f5 Fix #127 git-ignore won´t add duplicates.
| |/
|/|
* | 730ca89 (bolshakov) Rebase bolshakov with master
|/
* 60f8371 (origin/master, origin/HEAD, master) Merge pull request #126 from agrimaldi/fix-changelog-last-tag
* 9627780 (tag: 1.7.0) Release 1.7.0
* 2e53ff6 (tag: 1.6.0) Release 1.6.0
* bbd32d8 (tag: 1.5.1) Release 1.5.1
| * 6b6b758 (nickl/gh-pages, gh-pages) add example git-extras to gh-pages
| * 19cfd11 (origin/gh-pages) Index page
| | * 881a70e (tag: 1.5.0) Release 1.5.0
| |/
|/|
* | 4db5ee0 (tag: 1.4.0) Release 1.4.0
* | 9b0bc89 (tag: 1.3.0) Release 1.3.0
* | be49961 (tag: 1.2.0) Release 1.2.0
* | c1d2dfc (tag: 1.1.0) Release 1.1.0
* | 4a56adb (tag: 1.0.0) Release 1.0.0
* | 948308b (tag: 0.9.0) Release 0.9.0
* | 40b131d (tag: 0.8.1) Release 0.8.1
* | 391431d (tag: 0.8.0) Release 0.8.0
这是git show-tree 在ardupilot repo 上的示例输出:
另外,如果你安装了 arcanist(更正:Uber's fork of arcanist 已安装——请参阅the bottom of my answer here 以获取安装说明),arc flow 会显示一个漂亮的上游依赖关系树(即:之前通过arc flow new_branch 或通过git branch --set-upstream-to=upstream_branch 手动设置)。 arc flow 的示例输出:
master
└──graft-D999
└──new_feature_1
└──new_feature_2
我真的觉得arc flow 视图既漂亮又有用,所以我有这个(非活动的,还没有功能的)git tree 开源项目,我计划在其中复制它的行为:https://github.com/ElectricRCAircraftGuy/git-tree。
以“树状”的方式显示一个分支:
# Show the currently-checked-out branch
git lg
# OR: show branch_name
git lg branch_name
您可以添加-p 或--patch 以显示更改的行:
git lg -p
# OR
git lg --patch
要安装git lg 别名(来源:https://coderwall.com/p/euwpig/a-better-git-log):
git config --global alias.lg "log --color --graph \
--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) \
%C(bold blue)<%an>%Creset' --abbrev-commit"
显示sshfs repo 上的分叉和合并等内容的示例输出:
奖励 git 技巧:
相关:
- What's the difference between `arc graft` and `arc patch`?