Skip to content

Instantly share code, notes, and snippets.

@mkmik
Last active March 13, 2018 11:46
Show Gist options
  • Save mkmik/2a1a16a1fca05b716dfbf1ebf4bed5ca to your computer and use it in GitHub Desktop.
Save mkmik/2a1a16a1fca05b716dfbf1ebf4bed5ca to your computer and use it in GitHub Desktop.
show graph of git history relevant to current local branches

I like to use git command line. I use a simple alias ll = log --pretty=oneline --abbrev-commit --decorate=short --branches --graph for ages and I was almost happy. I realized I often just don't care about the old history though, but I do want to see how the current (active) I have relate to master (and to each other)

$ git branches
  something
*  something else
  master
  world
$ git ll
* a785a171 (something) Do something
| * 9b483389 (HEAD -> somethingelse) Do something else
|/
* 6d4c9d9a (origin/master, origin/HEAD, master) Something awesome
* b5c95bfc (origin/promoted) Something good
| * fb64255f (world) This will change the world
|/
* 0b2ff7ae Good stuff
$ 
#!/bin/bash
set -eu
oldest=$(git for-each-ref --sort=committerdate --format '%(refname)' refs/heads/ | head -n 1)
forkpoint=$(git merge-base --fork-point master ${oldest})
git log --pretty=oneline --abbrev-commit --decorate=short --branches --graph "${forkpoint}~1.."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment