154

I am using the command line version of Git and gitk. I want to see the full version tree, not just the part that is reachable from the currently checked out version. Is it possible?

petersohn
  • 11,292
  • 13
  • 61
  • 98

6 Answers6

353

if you happen to not have a graphical interface available you can also print out the commit graph on the command line:

git log --oneline --graph --decorate --all

if this command complains with an invalid option --oneline, use:

git log --pretty=oneline --graph --decorate --all
Community
  • 1
  • 1
knittl
  • 246,190
  • 53
  • 318
  • 364
  • 8
    who needs gitk when we have gitl! alias gitl='git log --oneline --graph --decorate --all' – Thunder Rabbit Feb 05 '13 at 01:30
  • 13
    `alias gl='git log --oneline --graph --decorate --all'`. Why type more than needed ;) – Dana Woodman Nov 18 '13 at 21:03
  • I have hope command line abbreviations were invented before tab completion. They only benefit those who use those commands a lot and those with crazy memories. – aaaaaa Dec 18 '17 at 17:33
147
  1. When I'm in my work place with terminal only, I use:

    git log --oneline --graph --color --all --decorate

    enter image description here

  2. When the OS support GUI, I use:

    gitk --all

    enter image description here

  3. When I'm in my home Windows PC, I use my own GitVersionTree

    enter image description here

checksum
  • 6,415
  • 4
  • 36
  • 34
  • Perfect answer for me. My OS supports GUI so second option is my way to go but let`s say I just wanna peek the graph from command line very quickly : is there some way to avoid typing all of those switches from the first version, or you just re-type them all the time ? Thank you. – rchrd May 15 '20 at 23:08
  • 2
    @rchrd I would set them as alias by running `git config --global alias.ver "log --oneline --graph --color --all --decorate"` and only need to type `git ver` thereafter. – checksum May 15 '20 at 23:58
92

You can try the following:

gitk --all

You can tell gitk what to display using anything that git rev-list understands, so if you just want a few branches, you can do:

gitk master origin/master origin/experiment

... or more exotic things like:

gitk --simplify-by-decoration --all
Mark Longair
  • 446,582
  • 72
  • 411
  • 327
28

There is a very good answer to the same question.
Adding following lines to "~/.gitconfig":

[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
Community
  • 1
  • 1
Daniil Shevelev
  • 11,739
  • 12
  • 50
  • 73
15

If you don't need branch or tag name:
git log --oneline --graph --all --no-decorate

If you don't even need color (to avoid tty color sequence):
git log --oneline --graph --all --no-decorate --no-color

And a handy alias (in .gitconfig) to make life easier:

[alias]
  tree = log --oneline --graph --all --no-decorate

Only last option takes effect, so it's even possible to override your alias:

git tree --decorate
clarkttfu
  • 577
  • 6
  • 11
-1
function gtree() {
  if [[ -n $DISPLAY ]] && which gitk; then
     gitk --all
  else
     git log --graph --pretty=online --abbrev-commit --all --decorate
  fi
}
Andreas Spindler
  • 7,568
  • 4
  • 43
  • 34