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?

share|improve this question
1  
I have created a python script to create a graphiz graph! Take a look. github.com/chode/git-graph – Stephan Bechter Sep 14 '14 at 8:13
    
If you want high-quality and printable, my tool (bit-booster.com/graph.html) converts "git log" into SVG. For more information, see my answer. – G. Sylvie Davies Oct 13 '16 at 18:44
    
Are you looking for a tool to visualize your own git history - or - a charting tool which has a way to draw pretty "Git branches"? – Uri Abramson Dec 18 '16 at 17:03
    
Possible duplicate of Visualizing branch topology in git – trblnc Jan 30 '17 at 11:48
    
I'd delete the tag directed-acyclic-graphs because it's irrelevant to this question – Maksim Dmitriev Jul 7 '17 at 20:24

27 Answers 27

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

enter image description here

share|improve this answer

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)'"
share|improve this answer

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)

share|improve this answer
    
How to read the color code...i think it only represents separate branches... – Jay Oct 18 '16 at 7:29
    
@Jay it appears the color reflects the indentation level of that particular branch, and that branches may move over to another column and therefore change color.s – Thorbjørn Ravn Andersen Oct 28 '16 at 9:57

I have this git log alias in ~/.gitconfig to view the graph history:

[alias]
l = log --all --graph --pretty=format:'%C(auto)%h%C(auto)%d %s %C(dim white)(%aN, %ar)'

With this in place, git l will output something like:

enter image description here

In Git 2.12+ you can even customize the line colors of the graph using the log.graphColors configuration option.

As for the logs' format, it's similar to --oneline, with the addition of the author name (respecting .mailmap) and the relative author date. Note that the %C(auto) syntax, which tells Git to use the default colors for commit hash, etc. is supported in Git >= 1.8.3.

share|improve this answer
    
git log --graph --oneline just to make sure oneliner didn't get lost – tsenapathy Feb 2 '17 at 9:43

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 --all --decorate --oneline --graph

enter image description here

share|improve this answer
3  
Define an alias for it! – Jubobs Dec 22 '16 at 10:08
29  
git config --global alias.adog "log --all --decorate --oneline --graph" – fracz Feb 9 '17 at 22:37
2  
Upvote for the nemonic device! – Joe Oct 19 '17 at 15:56
    
I'm up-voting this just because it is so easy to remember and run on other people's terminal where no git alias exists.. go figure those. – AmitP Oct 25 '17 at 13:29
    
Hahahaha amazing! I will never forget! – GabrielaBezerra Nov 16 '17 at 15:14

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.

share|improve this answer
1  
I tried this, but couldn't get dot to work correctly with the output for our repo (42 branches, 175 tags, 42.000 commits)... Too bad... That's exactly what I was looking for! – Xavier Nodet Dec 1 '13 at 20:39
    
@XavierNodet, if your repo is public and/or you have an error message etc., please file an issue on GitHub. Thanks! – Matt McHenry Dec 2 '13 at 3:30

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.

: 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

share|improve this answer
27  
Yeah, I do. Normal and bright/bold colors are: Black #202020/#555555, Red: #5d1a14/#da4939, Green: #424e24/#a5c261, Yellow: #6f5028/#ffc66d, Blue: #263e4e/#6d9cbe, Magenta: #3e1f50/#a256c7, Cyan: #234e3f/#62c1a1, and White: #979797/#ffffff. – Slipp D. Thompson Mar 21 '12 at 4:12
1  
@Turbo: For me, the colors are changeable in the profile settings for my terminal app (Terminal.app). The terminal app you're using may or may not support changing which colors are displayed for given ANSI colors. Also, the dash (em dash, accurately) was created with option-shift-[hyphen-minus key]. I suppose I wrongly assumed that all current platforms were up-to-snuff with Unicode. – Slipp D. Thompson May 5 '13 at 23:43
1  
Your --date=relative and --abbrev-commit are redundant because you explicitly use %cr and %h, respectively. – graywh Jun 7 '13 at 21:10
3  
I'd add the %C(auto) modifier to the refnames (%d) to get nicer colors. See stackoverflow.com/questions/5889878/color-in-git-log/… – Josef Eisl Feb 10 '16 at 10:55
1  
Great answer. I've modified the command to look more like the output of --oneline --decorate with lg = log --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset)%C(auto)%d%C(reset) %C(normal)%s%C(reset) %C(dim white)%an%C(reset) %C(dim blue)(%ar)%C (reset)' --all – Craig P. Motlin Feb 24 '16 at 23:02

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.

share|improve this answer
13  
i would add --abbrev-commit --decorate, and then it's perfect! – asymmetric Oct 7 '11 at 16:14
5  
--abbrev-commit is implied by --oneline, no? – dwineman Apr 10 '12 at 9:55
4  
@dwineman yes you don't need --abbrev-commit if you use --oneline – Thomas Sep 4 '12 at 11:54
2  
It seems that in your second line git log --graph --oneline --decorate --date=relative --all the --date argument is useless. I can see no date shown in the log. – lerner Feb 20 '16 at 6:21
    
date is not displayed when --oneline is specified – martinkunev Mar 7 '16 at 8:51

Gitgraph.js allows to draw pretty git branches without a repository. Just write a Javascript code that configures your branches and commits and render it in browser.

var gitGraph = new GitGraph({
   template: "blackarrow",
   mode: "compact",
   orientation: "horizontal",
   reverseArrow: true
});

var master = gitGraph.branch("master").commit().commit();
var develop = gitGraph.branch("develop").commit();
master.commit();
develop.commit().commit();
develop.merge(master);

sample graph generated with Gitgraph.js

or with metro template:

GitGraph.js metro theme

or with commit messages, authors, and tags:

GitGraph with commit messages

Test it with JSFiddle.

Generate it with Git Grapher by @bsara.

share|improve this answer
1  
Yay, that's totally amazing! Posted it into fiddle jsfiddle.net/guan1oz1 so you can test it out right away. – berkus Nov 5 '14 at 0:46
9  
The arrows should point to parent(s), though, not to children. – Jubobs Feb 4 '15 at 19:45
3  
@Jubobs: Good point. That's a common hurdle for people trying to understand Git: they think about the sequence of time instead of inheritance. Making it clear that (nearly) everything in git is relative to something prior helps all the other pieces fall into place. – Slipp D. Thompson Mar 2 '15 at 23:09
1  
@fracz: this is really cool. Thanks. One suggestion, however: please mention that even though the test webpage shows only no text, gitgraph.js does display commit messages, tags etc. if one download and open it locally. -- I suggest this because, at first, I thought it cannot display text and hence did not meet my needs. Fortunately, I didn't give up and downloaded gitgraph.js to my laptop. Turned out the actual output is pretty amazing and exactly what I want. :) – Lungang Fang Dec 10 '15 at 7:30
2  
FYI, after seeing this post and playing with gitgraph.js, I decided to create a little tool that basically puts a UI to gitgraph.js. It's not finished, and the UI isn't where I want it to be yet, but contributions are welcome! take a look: github.com/bsara/git-grapher – bsara May 16 '16 at 20:53

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

share|improve this answer
1  
That's the same graph code used on GitHub's impact graphs, no? (e.g. github.com/DmitryBaranovskiy/raphael/graphs/impact) – Slipp D. Thompson Mar 21 '12 at 4:18
    
All links are dead and no longer working. – Sven Jun 7 '16 at 8:47
    
@Sven: Thank you for pointing that out. I have corrected the broken links for you, although please bear in mind that this answer is five years old, and thus there may be a better solution more recently. – Spudley Jun 7 '16 at 20:45
    
@SlippD.Thompson this code is now at github.com/DmitryBaranovskiy/raphaeljs.com/tree/master/githu‌​b – Vadim Kotov Sep 5 '17 at 7:29

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.

share|improve this answer

I've added three custom commands: git tree, git stree and git vtree. I'll go over them in that order.

[alias]
    tree = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset) %C(auto)%d%C(reset)\n         %C(black)[%cr]%C(reset)  %x09%C(black)%an: %s %C(reset)'

enter image description here

With git stree and git vtree I've use bash to help with the formatting.

[alias]
    logx = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset)+%C(dim black)(%cr)%C(reset)+%C(auto)%d%C(reset)++\n+++       %C(bold black)%an%C(reset)%C(black): %s%C(reset)'
    stree = !bash -c '"                                                                             \
        while IFS=+ read -r hash time branch message; do                                            \
            timelength=$(echo \"$time\" | sed -r \"s:[^ ][[]([0-9]{1,2}(;[0-9]{1,2})?)?m::g\");     \
            timelength=$(echo \"16+${#time}-${#timelength}\" | bc);                                 \
            printf \"%${timelength}s    %s %s %s\n\" \"$time\" \"$hash\" \"$branch\" \"\";          \
        done < <(git logx && echo);"'

git_stree


[alias]
    logx = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset)+%C(dim black)(%cr)%C(reset)+%C(auto)%d%C(reset)++\n+++       %C(bold black)%an%C(reset)%C(black): %s%C(reset)'
    vtree = !bash -c '"                                                                             \
        while IFS=+ read -r hash time branch message; do                                            \
            timelength=$(echo \"$time\" | sed -r \"s:[^ ][[]([0-9]{1,2}(;[0-9]{1,2})?)?m::g\");     \
            timelength=$(echo \"16+${#time}-${#timelength}\" | bc);                                 \
            printf \"%${timelength}s    %s %s %s\n\" \"$time\" \"$hash\" \"$branch\" \"$message\";  \
        done < <(git logx && echo);"'

git_vtree


EDIT: This works with git version 1.9a. The color value 'auto' is apparently making its debut in this release. It's a nice addition because branch names will get a different color. This makes it easier to distinguish between local and remote branches for instance.

share|improve this answer
    
fatal: bad color value 'auto' for variable '--pretty format' :( – Swivel Apr 3 '14 at 16:40
    
Turned out to be an old version of git. Yum has a pretty outdated version of Git in its repo. Compiled from source (1.9) and it works great. It's beautiful too! Thanks @gospes! – Swivel Apr 3 '14 at 19:18
    
No go on OS X: sed: illegal option -- r – Slipp D. Thompson Apr 27 '14 at 3:34
    
@SlippD.Thompson: I'm using linux :). The -r is for extended regular expressions. Apparently the OSX version of sed doesn't have it. Perhaps you could update sed. Otherwise, you can just rewrite the sed command without extended regex. – gospes Apr 28 '14 at 7:51
1  
For the Mac OS X sed, use -E instead of -r – Baxter Lopez Jun 16 '15 at 0:04
git -c core.pager='less -SRF' log --oneline --graph --decorate

This is my terminal variation, similar to many answers here. I like to adjust the flags passed to less to prevent word wrapping.

example output

I set this to an alias for quick access since the command is a bit cumbersome.

share|improve this answer

Although sometimes I use gitg, always come back to command line:

[alias]
    #quick look at all repo
    loggsa = log --color --date-order --graph --oneline --decorate --simplify-by-decoration --all
    #quick look at active branch (or refs pointed)
    loggs  = log --color --date-order --graph --oneline --decorate --simplify-by-decoration
    #extend look at all repo
    logga  = log --color --date-order --graph --oneline --decorate --all
    #extend look at active branch
    logg   = log --color --date-order --graph --oneline --decorate
    #Look with date
    logda  = log --color --date-order --date=local --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ad%Creset %C(auto)%d%Creset %s\" --all
    logd   = log --color --date-order --date=local --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ad%Creset %C(auto)%d%Creset %s\"        
    #Look with relative date
    logdra = log --color --date-order --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ar%Creset %C(auto)%d%Creset %s\" --all
    logdr = log --color --date-order --graph --format=\"%C(auto)%h%Creset %C(blue bold)%ar%Creset %C(auto)%d%Creset %s\"  

    loga   = log --graph --color --decorate --all

    # For repos without subject body commits (vim repo, git-svn clones)
    logt  = log --graph --color --format=\"%C(auto)%h %d %<|(100,trunc) %s\"
    logta  = log --graph --color --format=\"%C(auto)%h %d %<|(100,trunc) %s\" --all        
    logtsa = log --graph --color --format=\"%C(auto)%h %d %<|(100,trunc) %s\" --all --simplify-by-decoration 

As you can see is almost a keystroke saving aliases, based on:

  • --color: clear look
  • --graph: visualize parents
  • --date-order: most understandable look at repo
  • --decorate: who is who
  • --oneline: Many times all you need to know about a commit
  • --simplify-by-decoration: basic for a first look (just tags, relevant merges, branches)
  • --all: saving keystrokes with all alias with and without this option
  • --date=relative (%ar): Understand activity in repo (sometimes a branch is few commits near master but months ago from him)

See in recent version of git (1.8.5 and above) you can benefit from %C(auto) in decorate placeholder %d

From here all you need is a good understand of gitrevisions to filter whatever you need (something like master..develop, where --simplify-merges could help with long term branches)

The power behind command line is the quickly config based on your needs (understand a repo isn't a unique key log configuration, so adding --numstat, or --raw, or --name-status is sometimes needed. Here git log and aliases are fast, powerful and (with time) the prettiest graph you can achieved. Even more, with output showed by default through a pager (say less) you can always search quickly inside results. Not convinced? You can always parse the result with projects like gitgraph

share|improve this answer
    
Very nice. Adding these to my config. But I recommend changing %Cred%d%Creset to be %C(auto)%d%Creset which will give different colors for remote or local branch names – MarkB42 Jul 1 '15 at 16:48

Depends on what they looked like. I use gitx which makes pictures like this one:

simple plot

You can compare git log --graph vs. gitk on a 24-way octopus merge (originally from http://clojure-log.n01se.net/date/2008-12-24.html):

24-way git octopus merge. Original URL was <code>http://lwn.net/images/ns/kernel/gitk-octopus.png</code>

share|improve this answer
43  
It's funny... I'd have sworn I heard you say "24-way octopus merge"! – dty Mar 23 '12 at 21:46
4  
Out of curiosity, has anyone attempted to extract GitX's (or another GUI git tool's) drawing routines into a standalone executable? If I'm not mistaken, getting Cocoa to draw into a vector PDF file wouldn't be difficult, and would satisfy the OP's need for high-Q printable imagery. – Slipp D. Thompson Oct 18 '12 at 21:15
    
It was on S3 via skitch before they redid their thing. I wish I still had it. :( – Dustin Jul 9 '13 at 19:37
    
Just replaced it with a gitk version from lwn.net/images/ns/kernel/gitk-octopus.png, linked from clojure-log.n01se.net/date/2008-12-24.html. @Dustin: hope that's ok. It's not the same image, but it serves a similar purpose. From the screen shot, it looks like that's part of the linux kernel, so I guess you could find that commit and re-take an equivalent gitx screenshot.... – naught101 Jul 12 '13 at 4:08

Gitg is a clone of Gitk and GitX for GNOME (it also works on KDE etc.) which shows a pretty colored graph.

It is actively developed (as of 2012). It lets you sort the commits (graph nodes) either chronologically or topologically, and hide commits that don't lead to a selected branch.

It works fine with large repositories and complex dependency graphs.

Sample screenshots, showing the linux-git and linux-2.6 repositories:

linux-git

linux-2.6

share|improve this answer

git-forest is an excellent perl script I've been using for more than a year and I hardly use the git log command directly any more.

These are some of the things I love about this script:

  • It uses unicode characters to draw the lines in the graph giving a more continuous look to the graph lines.
  • You can combine --reverse with the graph output, which is not possible with the regular git log command.
  • It uses git log internally to grab the list of commits, so all options that you pass to git log can also be passed to this script as well.

I have an alias using git-forest as follows:

[alias]
tree = "forest --pretty=format:\"%C(red)%h %C(magenta)(%ar) %C(blue)%an %C(reset)%s\" --style=15 --reverse"

This is how the output looks like on a terminal:

enter image description here

share|improve this answer
3  
Doesn't work on msysgit – void.pointer Jun 4 '14 at 16:38
3  
@void.pointer - Yes it won't because git-forest is a perl script and has perl module dependencies. Running git under cygwin with the required perl modules installed might be the best alternative you could get if you really want this on Windows :) – Tuxdude Jan 21 '15 at 22:47
1  
Wow, that repo has a lot of great tools. Thanks! – Eldelshell Sep 13 '15 at 17:09
1  
Works perfectly fine @MinGW(MSYS) under Win$; install CPANM; then Git.pm; create an alias and you are ready to go. – Sektor Feb 4 '16 at 9:30

For OSX users, I've taken the @gospes example and slightly modified it for gsed (gnu-sed installed via homebrew) and adjusted the colors (to work with a black background, not sure how the original example could possibly render the way it does in the example since it specifies black text on a terminal with a black background).

[alias]
    # tree, vtree, stree support
    logx = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset)+%C(bold black)(%cr)%C(reset)+%C(auto)%d%C(reset)++\n+++       %C(bold black)%an%C(reset)%C(bold black): %s%C(reset)'
    tree = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset) %C(auto)%d%C(reset)\n         %C(bold black)[%cr]%C(reset)  %x09%C(bold black)%an: %s %C(reset)'
    stree = !bash -c '" \
    while IFS=+ read -r hash time branch message; do \
        timelength=$(echo \"$time\" | gsed -r \"s:[^ ][[]([0-9]{1,2}(;[0-9]{1,2})?)?m::g\"); \
        timelength=$(echo \"16+${#time}-${#timelength}\" | bc); \
        printf \"%${timelength}s    %s %s %s\n\" \"$time\" \"$hash\" \"$branch\" \"\"; \
    done < <(git logx && echo);"' | less -r
    vtree = !bash -c '" \
    while IFS=+ read -r hash time branch message; do \
      timelength=$(echo \"$time\" | gsed -r \"s:[^ ][[]([0-9]{1,2}(;[0-9]{1,2})?)?m::g\"); \
      timelength=$(echo \"16+${#time}-${#timelength}\" | bc); \
      printf \"%${timelength}s    %s %s %s\n\" \"$time\" \"$hash\" \"$branch\" \"$message\"; \
    done < <(git logx && echo);"' | less -r

The key for OSX is to first install gnu sed (which has the -r option). Most easily done with homebrew, which will not overwrite the system-installed sed, but will instead install gnu sed as "gsed". Hope this helps @SlippD.Thompson who commented above about OSX not working.

share|improve this answer

Built on top of TikZ & PGF, gitdags is a little LaTeX package that allows you to effortlessly produce vector-graphics commit graphs, and more.

Automatic generation of an existing repository's commit graph is not the purpose of gitdags; the graphs it produces are only meant for educational purposes.

I often use it to produce graphs for my answers to Git questions, as an alternative to ASCII commit graphs:

Here is an example of such a graph demonstrating the effects of a simple rebase:

enter image description here

\documentclass{article}

\usepackage{subcaption}
\usepackage{gitdags}

\begin{document}

\begin{figure}
  \begin{subfigure}[b]{\textwidth}
    \centering
    \begin{tikzpicture}
      % Commit DAG
      \gitDAG[grow right sep = 2em]{
        A -- B -- { 
          C,
          D -- E,
        }
      };
      % Tag reference
      \gittag
        [v0p1]       % node name
        {v0.1}       % node text
        {above=of A} % node placement
        {A}          % target
      % Remote branch
      \gitremotebranch
        [origmaster]    % node name
        {origin/master} % node text
        {above=of C}    % node placement
        {C}             % target
      % Branch
      \gitbranch
        {master}     % node name and text 
        {above=of E} % node placement
        {E}          % target
      % HEAD reference
      \gitHEAD
        {above=of master} % node placement
        {master}          % target
    \end{tikzpicture}
    \subcaption{Before\ldots}
  \end{subfigure}

  \begin{subfigure}[b]{\textwidth}
    \centering
    \begin{tikzpicture}
      \gitDAG[grow right sep = 2em]{
        A -- B -- { 
          C -- D' -- E',
          {[nodes=unreachable] D -- E },
        }
      };
      % Tag reference
      \gittag
        [v0p1]       % node name
        {v0.1}       % node text
        {above=of A} % node placement
        {A}          % target
      % Remote branch
      \gitremotebranch
        [origmaster]    % node name
        {origin/master} % node text
        {above=of C}    % node placement
        {C}             % target
      % Branch
      \gitbranch
        {master}      % node name and text 
        {above=of E'} % node placement
        {E'}          % target
      % HEAD reference
      \gitHEAD
        {above=of master} % node placement
        {master}          % target
    \end{tikzpicture}
    \subcaption{\ldots{} and after \texttt{git rebase origin/master}}
  \end{subfigure}
  \caption{Demonstrating a typical \texttt{rebase}}
\end{figure}

\end{document}
share|improve this answer
1  
@That looks great! I would also like a few line on how to use it: consider a Windows user who has no LaTeX installed at all. How to produce a graph from scratch? – VonC Aug 28 '14 at 13:29
1  
@VonC I'm not sure, but if you don't want to install LaTeX, you might be able to produce your graphs on ShareLatex and WriteLaTeX, and the likes. I will look into it and expand the wiki when I have more time... Feel free to promote the package :) – Jubobs Aug 28 '14 at 13:34
    
This is great stuff! I'll write up a tutorial at some point, but for now, I just wanted to mention that you can post-process your graphs using the documentclass standalone (I use the crop feature), use latex input.tex to generate a dvi, and then finally use dvisvgm input.dvi to generate an SVG with transparency. Converting from the SVG to a raster format like PNG is easy enough with convert -antialias -density 300 -background none input.svg output.png. By the way, these images look amazing with full transparency. Still working on the font issue... i.imgur.com/1Xu2Ry5.png – vmrob Feb 4 '15 at 0:31
4  
It took me a while to get this working so I wrote a step-by-step guide how to get gitdags working from scratch on Ubuntu 14.04 – ChrisFreeman Feb 9 '15 at 10:38
1  
@AndreaPolci See github.com/Jubobs/gitdags/issues/3 for an example of a merge. The documentation for gitdags is on the way! – Jubobs Apr 1 '15 at 21:58

I just wrote one tool that can generate pretty git commits graph using HTML/Canvas.

And provide a jQuery plugin which make it easy to use.

[github] https://github.com/tclh123/commits-graph

Preview:

preview

share|improve this answer
    
Looks nice, how do you get preformatted data to draw this graph? – Olga Jan 27 '14 at 17:19
2  
@Olga I just add the backend code to my repo. You can view it on github. – Harry Lee Jan 29 '14 at 14:20

gitg: a gtk-based repository viewer, that's new but interesting and useful
http://git.gnome.org/browse/gitg
I use it currently

share|improve this answer
2  
It seems to be a clone of GitX and a pretty good one at that. Recommend – Yarek T Mar 1 '12 at 11:27

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/

share|improve this answer
    
It is also available in App Store, so update should work automatically. – WebOrCode Dec 8 '13 at 7:02
    
I love sourcetree's graph, but i'd rather use the command line, and sourcetree's defaults always mess with my repos. – SgtPooki Mar 14 '14 at 23:51
    
SourceTree would insist you create Atlassian account (or use your google account and grant Atlassian some permissions to get your email and profile info), and after install on Mac (OS X El Capitan v 10.11.5) it fails on 'Clonning' step: "fatal: no submodule mapping found in .gitmodules for path '<path skipped>'" and also a strange warning: "templates not found /usr/local/git/share/git-core/templates". Very obscure messages, not so great. – Dmitry Shevkoplyas Nov 23 '16 at 16:05
1  
And then after uninstall don't forget to tidy up your Google security privileges you granted earlier: myaccount.google.com/security -> Connected apps & sites -> Apps connected to your account -> Manage Apps – Dmitry Shevkoplyas Nov 23 '16 at 16:21

GitGraph

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

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

share|improve this answer
1  
Is this the same? gitgraphjs.com (looks really good.) – Andy Hayden Mar 17 '15 at 5:14
    
@AndyHayden: It's not. Totally different. Creates a git history graph using Dia – rzymek Oct 25 '17 at 9:46

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

gitlgBranch1 --all
share|improve this answer

For more detailed textual output, please try:

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

You can write alias in $HOME/.gitconfig

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

Did you try gitk or gitk --all ? However it doesn't have a print/save img as function.

share|improve this answer
3  
gitk is efficient but not very beautiful. – Johan Jun 29 '09 at 13:19

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.

share|improve this answer
    
Try this one github.com/gugod/bin/blob/master/git-graphviz . I didn't have all the dependencies in my corporate environment, so changing those io commands to simple perl `git log [...]` commands worked for me. – Ross Rogers May 5 '12 at 0:27
    
If you're on a mac and you want to try this script, you can grab perl with brew install perl dot and then cpan common::sense IO::all to get the dependencies. Then, just pipe the output to an appropriate command, like git-graphviz | dot -Tpng -o repo.png. However, the output isn't much different than git-big-picture. – jrhorn424 Oct 2 '13 at 2:26

protected by Jonathon Reinhart Sep 7 '15 at 20:23

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.