Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pretty Git branch graphs

Tags:

git

git-log

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?

like image 540
krosenvold Avatar asked Jun 29 '09 10:06

krosenvold


People also ask

How do you see visually branches in git?

Use git log --graph or gitk . (Both also accept --all , which will show all the branches instead of just the current one.)

What does -- decorate command do?

The --decorate flag makes git log display all of the references (e.g., branches, tags, etc) that point to each commit. This lets you know that the top commit is also checked out (denoted by HEAD ) and that it is also the tip of the main branch.

What does the command git log Oneline graph do?

git log by default shows the entire ancestry in order by birthdate (where timestamp weirdities don't make that contradict ancestry). Try it with git log --oneline --graph --decorate --first-parent . ^ or ^1 means the first parent.


Video Answer


2 Answers

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 two cents: 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


(Note: There now exists much more applicable answers to this question, such as fracz's, Jubobs', or Harry Lee's!)

like image 76
Slipp D. Thompson Avatar answered Sep 21 '22 12:09

Slipp D. Thompson


Many of the answers here are great, but for those that just want a simple one-line-to-the-point answer without having to set up 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

like image 29
Patoshi パトシ Avatar answered Sep 18 '22 12:09

Patoshi パトシ