Skip to content

Instantly share code, notes, and snippets.

@brwyatt
Last active March 17, 2016 09:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brwyatt/ea54cd0310e24785e898 to your computer and use it in GitHub Desktop.
Save brwyatt/ea54cd0310e24785e898 to your computer and use it in GitHub Desktop.
Create a directed graph from a Git repo using dot
#!/usr/bin/env bash
# based on http://chiu01.blogspot.com/2012/04/git-tip-using-graphviz-to-display.html
# Use: ./GraphGit.sh [FromCommitish] [ToCommitish]
echo 'digraph "git" {' > graph.dot
git log --pretty='format: %h [label="%h\n%an <%ae>\n%ai\n%s" shape=box]' $1..$2 | perl -p -e 's/([0-9a-f]{7})/"\1"/' >> graph.dot
git log --pretty='format: %h -> { %p }' $1..$2 | perl -p -e 's/([0-9a-f]{7})/"\1"/g' >> graph.dot
echo '}' >> graph.dot
dot -Tpng graph.dot -o graph.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment