Learn Git fast and well - by visualizing the inner graph of your Git repositories
Project description
Git-graph
Learn (or teach) Git fast and well - by visualizing the inner graph of your Git repositories
As wonderful as it may be, there is a downside coming with this "unusually rich command set", a kind of anxiety that affects beginners in particular and can be summed up in one question:
"What the hell is going to happen to my repository if I launch this Git command ?"
A good way to overcome this difficulty is to experiment.
This is made easy thanks to Git lightness and the fact it is immediately up and running in any directory with git init
.
Git-graph is a Git plugin, written in Python, that displays your Git repository inner content as a Directed Acyclic Graph (DAG). This structured visual representation of Git internal data demystifies the impact of each Git command and considerably improves the learning curve.
Install
From PyPI
To install Git-graph from PyPI:
- You first need to install Graphviz and check that the dot binary is correctly set in you system's path.
- Then run:
pip install git-graph
From GitHub
To install Git-graph from GitHub:
- You first need to install Graphviz and check that the dot binary is correctly set in you system's path.
- Then run:
git clone https://github.com/hoduche/git-graph
- Finally, inside the newly created git-graph folder, run (with Python 3 and setuptools):
python setup.py install
Run
As a Git plugin
Git-graph is a Git plugin that is run from a Git repository with the command:
git graph
Running git graph
from a Git repository will:
- scan your
.git
folder - build and save a graph representation of the
.git
folder internals as text (.dot
) and image (PDF by default) in a.gitGraph
folder - popup a window that displays the image of your graph
A color code helps in distinguishing in the graph the different kinds of object Git is using in its implementation:
Object kind | Letter | Representation | Object kind | Letter | Representation |
---|---|---|---|---|---|
blob | b | remote branch | r | ||
tree | t | remote head | d | ||
commit | c | remote server | s | ||
local branch | l | annotated tag | a | ||
local head | h | tag | g | ||
upstream link | u |
By default all nodes are displayed in the output graph when running git graph
.
It is possible to only display a user selection of object kinds using the -n
or --nodes
option and picking the letters corresponding to your choice.
For instance to only display blobs, trees and commits:
git graph -n btc
By default Git-graph considers it is launched from a Git repository.
It is possible to indicate the path to another Git repository with the -p
or --path
option:
git graph -p examples/demo
The default output format is PDF.
Other output graphics formats (either vector or raster) can be set with the -f
or --format
option:
(the full list of possible formats can be found on the Graphviz documentation website)
git graph -f svg
Finally it is possible to prevent the graph image from poping up once constructed, with the -c
or --conceal
option:
git graph -c
As a Python program
python git_graph/cli.py -p examples/demo -n btc -f svg
or
./git_graph/cli.py -p examples/demo -n btc -f svg
As a Python module
import git_graph.dot_graph as dg
dg.DotGraph('..').persist()
dg.DotGraph('../examples/demo', nodes='btc').persist(form='svg', conceal=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.