Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing branch hierarchy at the command line?

Tags:

git

I'm curious if there is a way to show branch hierarchy on the command line? For instance if I use git branch, instead of seeing output like this:

* master joes_work refactoring experiment 

You see output like this:

* master     joes_work     refactoring         experiment 

That way it's easy to see which branch a particular branch.. branched off of. Even if there's no specific command that outputs a tree structure, is there a command that outputs information on which branch came from which branch? I can use a perl script to format the output.

like image 451
mellowsoon Avatar asked Oct 01 '11 22:10

mellowsoon


People also ask

How do I find my github branch hierarchy?

Click the File menu, point to Source Control, point to Branching and Merging, and then click View Hierarchy.

Which command is used to see all the branches?

To see local branches, use the git branch command. The git branch command lets you see a list of all the branches stored in your local version of a repository.


2 Answers

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 
like image 56
ctcherry Avatar answered Sep 19 '22 03:09

ctcherry


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 
like image 40
sehe Avatar answered Sep 20 '22 03:09

sehe