1

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

Shreyan Mehta
  • 550
  • 5
  • 17
  • 1
    `git log --all --graph`? – Biffen Jul 03 '18 at 10:52
  • @Biffen thanks but that gives the complete graph of the complete git log, which includes all the remote branches and contributions by others too, this product has more than 70 dedicated developers, not able to find anything from it, I want similar branching graph of just local branches – Shreyan Mehta Jul 03 '18 at 11:00
  • 1
    I feel your pain, but I don’t know any existing solutions. I pretty much wonder to get the same in shell, though it’s not so easy as it sounds. First starting points are *git branch —contains...* and *git merge-base...* – 0andriy Jul 03 '18 at 11:45
  • @0andriy Ohh I wish, I would require couple of days (or months and a heap of coffee beans) i guess if I started doing so :/ – Shreyan Mehta Jul 03 '18 at 11:53

4 Answers4

2

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.

Sarath S Menon
  • 2,168
  • 1
  • 16
  • 21
  • Thanks for the link , i somehow found 2 workarounds and hacked in little bit for going accross your link(and across it's link and so on), will post as an answer so someone like me could get help in future, also give your comments on it if you do not like it and upvote if you like it , thanks – Shreyan Mehta Jul 04 '18 at 06:53
1

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

  • thanks @Aarushi, using gitg for quite a while now, but were working on vm based in us, and are not allowed to install 3rd party softwares unless they explicitly mention us to do so, but still thanks – Shreyan Mehta Jul 04 '18 at 05:57
1

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.

Steve Hollasch
  • 2,011
  • 1
  • 20
  • 18
0

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

Thiru
  • 2,541
  • 4
  • 25
  • 39