Setting git default flags on commands

You can use a custom format to have git log mimic --abbrev-commit by default:

git config format.pretty "format:%h %s"

There is no generic mechanism in git to set default arguments for commands.

You can use git aliases to define a new command with the required arguments:

git config alias.lg "log --oneline"

Then you can run git lg.

Some commands also have configuration settings to change their behavior.


I like the git log --oneline format. To get it as default, use

git config --global format.pretty oneline

Credit: https://willi.am/blog/2015/02/19/customize-your-git-log-format/


Since git version 1.7.6, git config has gained a log.abbrevCommit option which can be set to true. Thus the answer is upgrade to at least 1.7.6 (current as of this writing is 1.7.11.4) and use:

git config --global log.abbrevCommit true

Tags:

Logging

Git