Pretty git branch graphs

2018-12-31 09:59发布

I've seen some books and articles have some really pretty looking graphs of git branches and commits. How can I make high-quality printable images of git history?

标签: git git-log
30条回答
君临天下
2楼-- · 2018-12-31 10:40

Very slightly tweaking Slipp's awesome answer, you can use his aliases to log just one branch:

[alias]
lgBranch1 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lgBranch2 = log --graph --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(bold white)— %an%C(reset)' --abbrev-commit
lg = !"git lg1"

By leaving off the --all you can now do

git lgBranch1 <branch name>

or even

git lgBranch1 --all
查看更多
泛滥B
3楼-- · 2018-12-31 10:40

I don't know about a direct tool, but maybe you can hack a script to export the data into dot format and render it with graphviz.

查看更多
不流泪的眼
4楼-- · 2018-12-31 10:41

There's a funky Git commit graph as one of the demos of the Raphael web graphics library.

The demo is static, but it should be easy enough to take the code and swap out their static data for a live set of data -- I think it's just Git commit data in JSON format.

The demo is here: http://dmitrybaranovskiy.github.io/raphael/github/impact.html

查看更多
浅入江南
5楼-- · 2018-12-31 10:42

Many of the answers here are great, but for those that just want a simple one line to the point answer without having to setup aliases or anything extra, here it is:

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

Not everyone would be doing a git log all the time, but when you need it just remember:

"A Dog" = git log --all --decorate --oneline --graph

enter image description here

查看更多
琉璃瓶的回忆
6楼-- · 2018-12-31 10:43

I wrote a web tool for converting git logs into pretty SVG graphs: Bit-Booster - Offline Commit Graph Drawing Tool

Upload output from git log --pretty='%h|%p|%d' directly into the tool and then click on the "download graph.svg" link.

The tool is pure-client-side, and so none of your Git data is shared with my server. You can also save the HTML + JS locally and run it using "file:///" URL's. Verified on Chrome 48 and Firefox 43 on Ubuntu 12.04.

It generates HTML that can be posted directly into any page (including the blogspot blogging engine!). Take a look at some of the blog posts here:

http://bit-booster.blogspot.ca/

Here's a screenshot of a sample HTML file generated by the tool:

http://bit-booster.com/graph.html (the tool)

查看更多
谁念西风独自凉
7楼-- · 2018-12-31 10:43

GitGraph

Generates a PNG or SVG representation of your Git repository's commit history.

https://code.google.com/p/gitgraph

查看更多
登录 后发表回答