Skip to content

Instantly share code, notes, and snippets.

@ckarnell
Created November 8, 2017 19:04
Show Gist options
  • Save ckarnell/f54aeb34693620fb032d2fb780404d97 to your computer and use it in GitHub Desktop.
Save ckarnell/f54aeb34693620fb032d2fb780404d97 to your computer and use it in GitHub Desktop.
# Add these to your .bashrc for fancy git logging:
# This optionally accepts a number as an argument (e.g. `gl 10`) to show that many commits.
# `gl` by itself will show all commits like a normal `git log`.
function gl {
if [ -z "$1" ]
then
git log --pretty=format:'%C(bold blue)%h %C(bold green)(%ar) %C(magenta)%an %Creset%s%C(bold yellow)%d'
else
git log --pretty=format:'%C(bold blue)%h %C(bold green)(%ar) %C(magenta)%an %Creset%s%C(bold yellow)%d' -$1
fi
}
# Here's the same thing except you get to see a useless tree graph of the commits:
function glg {
if [ -z "$1" ]
then
git log --graph --abbrev-commit --decorate --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)' --all
else
git log --graph --abbrev-commit --decorate --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)' --all -$1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment