简体   繁体   English

git 别名可以像 bash 别名一样扩展吗?

[英]Can a git alias be expanded like a bash alias?

If I set the alias alias gf='git fetch --prune'如果我设置别名alias gf='git fetch --prune'

I can enter it into my command line $ gf and by typing <ESC> <Ce> it will expand into $ git fetch --prune我可以将它输入我的命令行$ gf并通过键入<ESC> <Ce>它将扩展为$ git fetch --prune

If I set the git alias git config --global alias.f fetch --prune and type $ git f does git offer a way of expanding this alias?如果我设置 git 别名git config --global alias.f fetch --prune并输入$ git f git 是否提供了扩展此别名的方法?

From what I can tell the only way to know what $ git f will do when executed is by inspecting git's config beforehand.据我所知,知道$ git f在执行时会做什么的唯一方法是事先检查 git 的配置。

Not really, considering git aliases can also include shell expansion definition aliases with positional parameters like "!f() { echo \\"$1\\" >> .gitignore; }; f".并非如此,考虑到 git 别名还可以包括带有位置参数的shell 扩展定义别名,例如"!f() { echo \\"$1\\" >> .gitignore; }; f". . .

And that would be tricky to expand on the shell level.在 shell 级别上扩展会很棘手。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM