I like the way that the following command prints out git logs:
git log --oneline --decorate --graph
I would like to make that the default format whenever I use git log.  Is there a way to edit ~/.gitconfig to enable oneline, decorate, and graph by default?
And yes, I'm aware that I can alias those options to another git command alias, but I'd rather that log just print out using those options by default.
Git allows you to activate --oneline and --decorate by default for log, show, etc.:
git config --global format.pretty oneline
git config --global log.decorate short
However, as of v2.1.0 v2.2.2, Git does not allow you to activate --graph by default. One way around that (adapted from this SuperUser answer) is to define the following function in your .<shell>rc file:
git() {
    if [ "$1" = "log" ]
    then
        command git log --graph "${@:2}";
    else
        command git "$@";
    fi;
}
One caveat (pointed out by hvd in his comment): if you specify options between git and log, as in
git -c log.showroot=false log -p
then, because the first argument is -c and not log, the --oneline --decorate --graph flags won't be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With