定义具有相同名称的git别名来隐藏原始命令

定义具有相同名称的git别名来隐藏原始命令

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

问题描述

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

 给出了彩色输出作为默认值。     $ c>没有可配置的选项,最好的办法就是制作一个别名不同的别名。例如: 

  [别名] 
rmc = rm --cached

您可能已经知道了这一点,但是Git别名不能影射现有的Git命令。从:

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.

EditSetting 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:

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

08-22 20:23