Enabling default git log options

I like the way the following command outputs git logs:

git log --oneline --decorate --graph 

I would like to make this the default format when I use git log. Is there any way to edit ~/.gitconfig to enable oneline, decorate and default schedule?

And yes, I know that I can use these options for another alias of the git command, but I would prefer that the log just print these options by default.

+5
source share
1 answer

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, with v2.1.0 v2.2.2, Git does not allow you to activate --graph by default. One way (adapted from SuperUser from this answer ) is to define the following function in your file .<shell>rc :

 git() { if [ "$1" = "log" ] then command git log --graph "${@:2}"; else command git " $@ "; fi; } 

One warning (indicated by hvd in his comment ): if you specify options between git and log , as in

 git -c log.showroot=false log -p 

because the first argument is -c , not log , the --oneline --decorate --graph flags will not be used.

+3
source

Source: https://habr.com/ru/post/1201972/


All Articles