Showing branch hierarchy at the command line?

sehe's solution looks great, here is another one that seems to contain similar information, formatted differently, it uses git log, so it contains commit information as well (ignore the branch names, I kind of messed them up!):

git log --all --graph --decorate --oneline --simplify-by-decoration

* ae038ad (HEAD, branch2-1) add content to tmp1
| * f5a0029 (branch2-1-1) Add another
|/  
* 3e56666 (branch1) Second wave of commits
| * 6c9af2a (branch1-2) add thing
|/  
* bfcf30a (master) commit 1

Try

git show-branch
git show-branch --all

Example output:

bash$ git show-branch --all
! [branchA] commitA only in branchA
 * [branchB] commitB
  ! [branchC] commitC only in branchC
---------------------
+   [branchA] commitA only in branchA 
 *  [branchB] commitB
  + [branchC] commitC only in branchC
 *+ [branchC~1] commitB-1 also in branchC
 *+ [branchC~2] commitB-2 also in branchC
+++ [branchC~3] common ancestor
+++ [branchC~4] more common ancestors

I want to complete the answer of @ctcherry.

I like when I can also see the user who did the commit and the date, so this is the following line to use :

git log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

However this is a pretty long line and difficult to memorize so you can use an alias. You just have to use this in your terminal :

git config --global alias.lg "HERE GOES MY BIG LOG COMMAND LINE"


To summarize copy and paste the line below on your terminal:

git config --global alias.lg "log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Then you will just have to use git lg to get your log history tree.

Example: enter image description here

src


Just type gitk command and press enter.

For me gitk is the easiest solution for this. Though it will not show you command mode, it will automatically populate a nice UI like this :

enter image description here