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


当前回答

Gitg是GNOME的Gitk和GitX的克隆(它也适用于KDE等),它显示了一个漂亮的彩色图形。

它正在积极开发(截至2012年)。它允许您按时间顺序或拓扑顺序对提交(图形节点)进行排序,并隐藏不会导致选定分支的提交。

它适用于大型存储库和复杂的依赖关系图。

示例屏幕截图,显示linuxgit和linux-2.6存储库:

其他回答

文件~/.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'

对于文本输出,您可以尝试:

git log --graph --abbrev-commit --decorate --date=relative --all

Or:

git log --graph --oneline --decorate --all

或者:这里有一个Graphviz别名,用于绘制DAG图。

我个人使用gitx、gitk-all和gitnub。

除了“Slipp D.Thompson”的答案外,我建议您添加此别名以具有相同的装饰,但通过提交将其添加到单行中:

git config --global alias.tre "log --graph --decorate --pretty=oneline --abbrev-commit --all --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)'"

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

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

要获得更详细的文本输出,请尝试:

git log --graph --date-order -C -M --pretty=format:"<%h> %ad [%an] %Cgreen%d%Creset %s" --all --date=short

您可以在文件$HOME/.gitconfig中添加别名:

[alias]
    graph = log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short