Pretty git branch graphs

前端 未结 30 2023
情话喂你
情话喂你 2020-11-22 01:34

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?

相关标签:
30条回答
  • 2020-11-22 02:14

    I suggest tig https://github.com/jonas/tig , a much much better command line tool for git.

    You can use homebrew to install tig on macOS:

    $ brew install tig
    $ tig
    

    0 讨论(0)
  • 2020-11-22 02:15

    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+.

    Example output in Sourcetree

    0 讨论(0)
  • 2020-11-22 02:16

    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.

    My 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:
    git lg1

    and git lg2 looks like this:
    git lg2

    0 讨论(0)
  • 2020-11-22 02:16

    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.

    0 讨论(0)
  • 2020-11-22 02:17

    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:

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

    0 讨论(0)
  • 2020-11-22 02:18

    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.

    0 讨论(0)
提交回复
热议问题