在命令上设置git默认标志 [英] Setting git default flags on commands

查看:96
本文介绍了在命令上设置git默认标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法为git命令默认设置标志。具体来说,我想设置 - abbrev-commit 标志,这样当执行 git log 时,我想执行 git log --abbrev-commit



与问题是否有任何方法可以为git命令默认设置一个标志?,显然没有用于将--abbrev-commit添加到git日志的配置标志。此外,git手册指出我无法创建别名:为避免混淆脚本,忽略隐藏现有git命令的别名



我的第三个选择是发明一个新的别名,比如 glog = log --abbrev -commit 在我的.gitconfig文件中。但我宁愿不用新命令创造我自己的DSL。

是否有另外一种方法来实现它,以便默认设置 abbrev-commit 标志?

解决方案

由于git版本1.7.6,git config获得了可以设置为true的log.abbrevCommit选项。因此,答案是升级到至少1.7.6(截至撰写本文时为1.7.11.4)并使用:

  git config --global log.abbrevCommit true 


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??

解决方案

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

这篇关于在命令上设置git默认标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆