Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
in DevOps and Agile by (29.3k points)

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?

2 Answers

0 votes
by (50.2k points)

For less number of branches we can use this command:

git log --graph --pretty=oneline

But in order to make the graph more pretty, you can do it in several ways

Generally, I have two aliases that I will throw in my ~/.gitignore file:


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"

After adding this to ~/.gitignore file the graphs are displayed on git log becomes prettier than earlier.

You can write your formats to make your branch graphs different.


+1 vote
by (27.5k points)


To show the history of the current branch

$ git hist 

To show the graph of all branches (including remotes)

$ git hist --all 

To show the relationship between two or more branches

$ git hist master devel 

To show all local branches

$ git hist --branches 

Add --topo-order to sort commits topologically, instead of by date (default in this alias)


  • It looks just like plain --decorate, so with separate colors for different branch names
  • It adds committer email
  • It adds commit relative and absolute date
  • Also, it sorts commits by date 

Let us look at the setup:

$ git config --global alias.hist "log --graph --date-order --date=short \ --pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)Î %C(reset)%C(green)%cr (Í)'"

Related questions

Browse Categories