Pretty git branch graphs
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?
Update: This answer has gotten far more attention than it deserves. It was originally posted because I think the graphs look nice and they could be drawn-over in Illustrator for a publication– and there was no better solution. But there now exists much more applicable answers to this Q, such as fracz's, Jubobs', or Harry Lee's! Please go upvote those!!
Update 2: I've posted an improved version of this answer to the Visualizing branch topology in git question, since it's far more appropriate there. That version includes lg3
, which shows both the author and committer info, so you really should check it out. Leaving this answer for historical (& rep, I'll admit) reasons, though I'm really tempted to just delete it.
2¢ : I have two aliases I normally throw in my ~/.gitconfig
file:
[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
looks like this:
and git lg2
looks like this:
Many of the answers here are great, but for those that just wants 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 -- a ll -- d ecorate -- o neline -- g raph
For textual output you can try:
git log --graph --abbrev-commit --decorate --date=relative --all
or:
git log --graph --oneline --decorate --all
or: here's a graphviz alias for drawing the DAG graph.
I personally use gitx
, gitk --all
and gitnub
.
上一篇: 如何修改旧的Git提交?
下一篇: 漂亮的git分支图