【发布时间】:2011-01-30 19:56:36
【问题描述】:
我想知道是否有办法为 git 命令默认设置标志。具体来说,我想设置--abbrev-commit标志,以便在执行git log时,我想执行git log --abbrev-commit。
与问题“is there any way to set a flag by default for a git command?”不同,显然没有将 --abbrev-commit 添加到 git log 的配置标志。此外,git手册指出我无法创建别名:"To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored"
我的第三个选择是在我的 .gitconfig 文件中创建一个新的别名,例如 glog=log --abbrev-commit。但我宁愿不要用新命令发明我自己的 DSL。
有没有其他方法可以实现默认设置abbrev-commit标志??
【问题讨论】:
-
从 git 1.7.6 开始,有一个标志可以控制这种行为。请参阅下面@underrun 的答案。