A. Hasan
A. Hasan

Reputation: 3

How to visualize branches in git (topology), where git log --graph doesn't show them?

I'm trying to visualizing the git branch topology, but when I use $git log --graph it's been shown as a series of commits.

$ git log --graph --all --oneline

* 5c27c47 (tbranch) tbranch commit
* 01a5a93 (HEAD -> master) commit
* c49cb49 rename
* 337bd9a new file added
* bcc3d2c delete new 2
* 16e2af4 new file added
* 6984275 trying -a commit
* 1ff68e2 gif diff reviewed
* 04add98 experincing git diff
* cf34191 changed the text file
* 0ca946e new file added

I wanted it to be shown something like this:

| * commit

| * commit

| * commit

|/

|*commit

Upvotes: 0

Views: 185

Answers (1)

torek
torek

Reputation: 490168

The graph shown here:

* 5c27c47 (tbranch) tbranch commit
* 01a5a93 (HEAD -> master) commit
* c49cb49 rename
* 337bd9a new file added
* bcc3d2c delete new 2
* 16e2af4 new file added
* 6984275 trying -a commit
* 1ff68e2 gif diff reviewed
* 04add98 experincing git diff
* cf34191 changed the text file
* 0ca946e new file added

does have two branches, but the two branches are linear with each other, not parallel to each other. So git log --graph displays them that way.

More specifically, it appears that the parent of 5c27c47 (the tip of tbranch) is 01a5a93 (the tip of master, which you have checked-out as well). The parent of 01a5a93 is c49cb49, and so on. If we draw these horizontally, instead of vertically, we get:

...--o--o   <-- master (HEAD)
         \
          o   <-- tbranch

where the round os represent the commits without showing their hash IDs.

If you had this (where I've added one more commit to master):

...--o--o--o   <-- master (HEAD)
         \
          o   <-- tbranch

then when git log prints this graph vertically, you will see what you want to see:

* nnnnnnn (HEAD -> master) nnnnnnn's subject
| * 5c27c47 (tbranch) tbranch commit
|/
* 01a5a93 commit
* c49cb49 rename
...

but right now there's no need for git log --graph --all --oneline to bother doing that, so it doesn't.

Upvotes: 1

Related Questions