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:43

In addition to the answer of 'Slipp D. Thompson', I propose you to add this alias to have the same decoration but in a single line by commit :

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)'"
查看更多
余生无你
3楼-- · 2018-12-31 10:44

Based on a Graphviz script I found in an answer to a related question, I've hacked up a ruby script that creates a summary view of a git repository. It elides all linear history and just shows "interesting" commits, i.e. those with multiple parents, multiple children, or pointed to by a branch or tag. Here's a snippet of the graph it generates for jquery:

jquery sample

git-big-picture and BranchMaster are similar tools that try to show only the high-level structure of a graph, by only displaying how tags, branches, merges, etc. are related.

This question has some more options.

查看更多
十年一品温如言
4楼-- · 2018-12-31 10:47

This is my take on this matter:

Screenshot:

Screenshot

Usage:

git hist - Show the history of current branch

git hist --all - Show the graph of all branches (including remotes)

git hist master devel - Show the relationship between two or more branches

git hist --branches - Show all local branches

Add --topo-order to sort commits topologically, instead of by date (default in this alias)

Benefits:

  • Looks just like plain --decorate, so with separate colors for different branch names
  • Adds committer email
  • Adds commit relative and absolute date
  • Sorts commits by date

Setup:

git config --global alias.hist "log --graph --date-order --date=short \
--pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)%ce %C(reset)%C(green)%cr (%cd)'"
查看更多
春风洒进眼中
5楼-- · 2018-12-31 10:47

Try ditaa. It can transform any ASCII diagram into an image. Although is was not designed with Git branches in mind, I was impressed by the results.

Source (txt file):

        +--------+
        | hotfix |
        +---+----+
            |
--*<---*<---*
       ^ 
       |
       \--*<---*
               |
           +---+----+
           | master |
           +--------+

Command:

java -jar ditaa0_9.jar ascii-graph.txt

Result:

enter image description here

It also supports background colors, dashed lines, different shapes and more. See the examples.

查看更多
与君花间醉酒
6楼-- · 2018-12-31 10:48

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.

查看更多
几人难应
7楼-- · 2018-12-31 10:49

SourceTree is a really good one. It does print out a good looking and medium size history and branch graph: (the following is done on an experimental Git project just to see some branches). Supports Windows 7+ and Mac OS X 10.6+.

enter image description here

http://www.sourcetreeapp.com/

查看更多
登录 后发表回答