user1516425
user1516425

Reputation: 1571

Condense git log --graph output?

Is there a way to condense the output of git log --graph so it'll visually squash commits that follow a linear history? Basically, I just want to see the points in the graph where some branches diverge/merge to get an top-level 'overview' of what my branch structure looks like. As an example, if I had this:

A
|
Z
|
H
|
B    G
|   /
C  F
| /
D
|
E

I'd want it to show something like:

A    G
|   /
.. ..
| /
D
|
E

Upvotes: 3

Views: 498

Answers (1)

VonC
VonC

Reputation: 1323753

Building on Ismail Badawi's comment, I like:

git log --simplify-by-decoration --graph --format="%d"

On the git repo itself, that would give:

C:\Users\vonc\prog\git\git>git log --simplify-by-decoration --graph --format="%d"
*  (HEAD, origin/master, origin/HEAD, master)
*  (tag: v1.9.1)
*  (tag: v1.9.0)
*
|\
| *  (tag: v1.8.5.5)
* |  (tag: v1.9.0-rc3)
* |
|\ \
| |/
| *  (tag: v1.8.5.4)
* |  (tag: v1.9-rc2)
* |  (tag: v1.9-rc1)

Slightly longer:

git log --simplify-by-decoration --graph --pretty="format:%H%n" | git name-rev --stdin --name-only | less

In multiple lines:

git log --simplify-by-decoration --graph --pretty="format:%H%n" | \ 
  git name-rev --stdin --name-only | \
  less

On the git repo itself, that would give:

C:\Users\vonc\prog\git\git>git log --simplify-by-decoration --graph --pretty="format:%H%n" | git name-rev --stdin --name-only | less
* master
|
* tags/v1.9.1^0
|
* tags/v1.9.0^0
|
*   tags/v1.9.0~2
|\
| |
| * tags/v1.8.5.5^0
| |
* | tags/v1.9.0-rc3^0
| |
* |   tags/v1.9.0-rc3~4
|\ \
| |/
| |
| * tags/v1.8.5.4^0
| |
* | tags/v1.9-rc2^0

Upvotes: 2

Related Questions