定义具有相同名称的git别名来隐藏原始命令 [英] Define git alias with the same name to shadow original command

查看:107
本文介绍了定义具有相同名称的git别名来隐藏原始命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用与现有命令相同的别名作为别名,以便别名会遮挡原始命令(防止我从正在工作的树中删除文件)。

  [别名] 
rm = rm - 缓存
diff = diff --color

不幸的是,这不起作用。有谁知道解决方法?
Thanks。



编辑
设置 color.diff = true rm --cached 给出了彩色输出作为默认值。 $ c>没有可配置的选项,最好的办法就是制作一个别名不同的别名。例如:

  [别名] 
rmc = rm --cached

您可能已经知道了这一点,但是Git别名不能影射现有的Git命令。从 git-config 手册页

lockquote

为了避免混淆和脚本使用的麻烦,隐藏现有git命令的别名被忽略。



I'm trying to use to use the same name for an alias as the existing command, so that the alias shadows the original command (preventing me from deleting files off the working tree).

[alias]
   rm = rm --cached
   diff = diff --color

Unfortunatly this is not working. Does anyone know a workaround? Thanks.

Edit Setting color.diff = true gives colored output as default.

解决方案

For commands like rm --cached that don't have configurable options, your best bet is to just make an alias named differently. For example:

[alias]
        rmc = rm --cached

You may have already figured this out, but Git aliases cannot shadow existing Git commands. From the git-config man page:

To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored.

这篇关于定义具有相同名称的git别名来隐藏原始命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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