how to check nesting structure of local git repository

2.1k Views Asked by At

I am working on a big product as a developer, I have many local branches, I wanted to visualize the git branch nesting workflow, i.e. say

master---------
     \
      \
      branch a--------
              \
               \
                branch child----

How can I get something like this I searched a lot but I found workarounds, which won't be useful in my case, like checking the complete log, etc, is there another way towards this issue.

Also previously another developer who left the company was working on the same pc and repo, so there are more than 50 branches so it's very essential for me to understand the workflow he was having in local

4

There are 4 best solutions below

1
Sarath S Menon On BEST ANSWER

The closest way to view branches in a tree like structure is using the git log command.

git log --graph --simplify-by-decoration --pretty=format:'%d' --all

See this answer for more info on this.

1
Thiru On

From the git log documentation:

git log --branches --not --remotes=origin

Shows all commits that are in any of local branches but not in any of remote-tracking branches for origin (what you have that origin doesn’t).

git log master --not --remotes=*/master

Shows all commits that are in local master but not in any remote repository master branches.

Check if this helps

Edit 1

git log --graph --branches --not --remotes=origin

1
Aarushi Sharda On

You can try using gitg or any similar visual representation tool. They will give you a simpler way to view the nesting structure and also you can search for commits like what you get in git branch --contains ( without having to buy heaps of coffee beans ;) )

0
Steve Hollasch On

This is what I use when I'm more interested in the shape of my branching structure than in the specific commits themselves. Not a beautiful render, but succinct.

git log --decorate --all --graph --simplify-by-decoration --topo-order --date=short --format='%h [%cd]%d %s'

I have this stored as an alias named shape.