I want to know if there is a way to set a flag by default for git command. Specifically, I want to set the --abbrev-commit
flag so that when executing git log
, I want to execute git log --abbrev-commit
.
Unlike the question "is there any way to set a flag by default for a git command?", there is apparently not a configuration flag for adding --abbrev-commit to git log. Furthermore, the git manual states that I cannot create an alias: "To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored"
My third option is to invent a new alias like glog=log --abbrev-commit
in my .gitconfig file. But I'd rather not invent my own DSL with new commands.
Is there another way to achieve it so that the abbrev-commit
flag is set by default??
By using the -a flag when committing you are telling Git to add all files that have been modified and then commit them. This runs into issues with new files, though. Since the -a flag only adds modified files it will not add new files or deleted files.
Show global git config settings But at runtime, only the value set locally is used. If you would like to delete or edit a Git config value manually with a text editor, you can find the Git config file locations through the Git config list command's –show-origin switch.
The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to . gitconfig text files. Executing git config will modify a configuration text file.
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
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