Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing Git branch structure

Is there a way to show only the branch structure in Git? There are a number of tools that show the commits graphically, but in my case the list is so long that it's impossible to see the structure. I guess git-log could be the answer, but I can't find any switches that only show the branching commits. This along with "--graph --branches --oneline --all" could do the trick.

EDIT: I'm looking for a way to do this in Ubuntu.

like image 355
Makis Avatar asked Sep 08 '10 10:09

Makis


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.)


2 Answers

I am not sure about what you mean by "branch structure".
git log can help visualize the branches made through commits (See this blog post):

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

alt text

But if you only wants the different HEAD branches, you could try something along the lines of:

heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'" 

(using the column command, and here only for commits since the last origin/master commit)

Note: Jakub Narębski recommands adding the option --simplify-by-decoration, see his answer.

like image 136
VonC Avatar answered Oct 02 '22 15:10

VonC


Perhaps what you want is --simplify-by-decoration option, see git log documentation:

--simplify-by-decoration

     Commits that are referred by some branch or tag are selected.

So it would be

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

or following VonC answer

git log --graph --simplify-by-decoration \    --pretty=format:'%Cred%h%Creset-%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' \    --abbrev-commit --date=relative 
like image 24
Jakub Narębski Avatar answered Oct 02 '22 14:10

Jakub Narębski