我见过一些书籍和文章中有一些非常漂亮的Git分支和提交的图表。如何制作Git历史的高质量可打印图像?


当前回答

文件~/.oh-my-zsh/plugins/git/git.plugin.zsh中的一些别名:

gke='\gitk --all $(git log -g --pretty=%h)'
glg='git log --stat'
glgg='git log --graph'
glgga='git log --graph --decorate --all'
glgm='git log --graph --max-count=10'
glgp='git log --stat -p'
glo='git log --oneline --decorate'
glog='git log --oneline --decorate --graph'
gloga='git log --oneline --decorate --graph --all'
glol='git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit'
glola='git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --all'

其他回答

如果您正在使用macOS,可以尝试GitUp:

x轴:分支y轴:时间

看着这段对话,我试着用我最喜欢的git可乐和git dag。

正在运行视图->DAG。。。从git-cola中删除并替换Log:master-with-都显示了一个包含所有分支的漂亮图形。

我在~/.gitconfig中有这个git日志别名来查看图形历史:

[alias]
l = log --all --graph --pretty=format:'%C(auto)%h%C(auto)%d %s %C(dim white)(%aN, %ar)'

有了这一点,git l将输出如下内容:

在Git2.12+中,您甚至可以使用log.graphColors配置选项自定义图形的线条颜色。

至于日志的格式,它类似于--oneline,添加了作者名(尊重.mailmap)和相对作者日期。请注意,在Git>=1.8.3中支持%C(auto)语法,告诉Git使用提交散列等的默认颜色。

如果您的存储库位于GitLab上,您可以使用它的图形表示,因为它在浏览器中呈现为SVG。

转到存储库的图形视图,例如。,https://gitlab.com/gitlab-org/gitter/webapp/network/develop将图形向下滚动到底部(它会延迟加载提交!)使用浏览器的检查器将SVG元素复制到新文件在您选择的渲染器中打开它,例如Inkscape

更新2:我发布了Git中可视化分支拓扑问题的改进版本,因为它更合适。该版本包含lg3,它显示了作者和提交者的信息,因此您确实应该检查一下。出于历史原因(我承认)留下这个答案,尽管我真的很想删除它。

我的两分钱:我通常在~/.gitconfig文件中使用两个别名:

[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"

git lg/git lg1如下所示:

git lg2看起来像这样:


(注意:现在有更多适用于此问题的答案,例如fracz、Jubobs或Harry Lee的!)