6

I would like to see the branch topology of my git repository in a nutshell, without visualizing the whole commit history at the same time, which makes the branch visualization hard to read.

For example, here is what I get by following the command given here

$ git log --graph --full-history --all --pretty=format:"%h%x09%d%x20%s"
* 822458d        (HEAD -> branch2) revision 5
* 1057127        revision 4
| * ae46e7e      (branch1a) revision 3
| * 39cd7e2      (branch1) revision 2
| * 6802061      revision 1 
|/  
* f8c8522        (master) start

While what I want is just the topology of the branches, without the commit historym i.e. something like this

branch2
|          branch1a
|         /
| branch 1
|/  
(master)

Do you guys know how to achieve this in git?

Thank you.

James
  • 383
  • 1
  • 4
  • 15
  • 1
    Keep in mind that a branch is just a pointer on **one** commit. The fact you can trace a branch's history is because the commit it points to has parents which have parents, and so on. I get that you search for a better visualization, but commits *are* the only topology we have, so it'll have to be used to produce the display you seem to search for. – Romain Valeri Aug 14 '18 at 09:39

1 Answers1

10
git log --all --decorate --oneline --graph --simplify-by-decoration

The --simplify-by-decoration option allows you to view only the big picture of the topology of the history, by omitting commits that are not referenced by tags. Commits are marked as !TREESAME (in other words, kept after history simplification rules described above) if (1) they are referenced by tags, or (2) they change the contents of the paths given on the command line. All other commits are marked as TREESAME (subject to be simplified away).

Amadan
  • 191,408
  • 23
  • 240
  • 301
  • Doesn't work on my 1.7.10.4 version :'-( But neat feature anyway! – Romain Valeri Aug 14 '18 at 09:54
  • @RomainVALERI Really? Because it seems it's been in Git for [10 years now](https://github.com/git/git/commit/78892e32616f00bf173496ca0502aff2e523db31). I might be wrong... And yeah, I tested on my 2.15.2, which seems a far way off from 1.7.10.4... Why not update? :) – Amadan Aug 14 '18 at 09:59
  • This is a work environment I don't control :-) But thanks anyway for shamelessly rubbing it in my nose! Just kidding, of course, it'll be very useful eventually. – Romain Valeri Aug 14 '18 at 10:03
  • 1
    @RomainVALERI: `--simplify-by-decoration` is in Git starting with v1.6.1; it *should* be in 1.7.10.4. But wow, 1.7.anything is old... – torek Aug 14 '18 at 21:51
  • This kinda works in gitk as well. I used `gitk --all --simplify-by-decoration` , since `--decorate`, `--oneline` and `--graph` don't make sense in already graphical gitk. – Tulains Córdova Aug 07 '22 at 13:42