Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a git alias be expanded like a bash alias?

Tags:

git

alias

bash

If I set the alias alias gf='git fetch --prune'

I can enter it into my command line $ gf and by typing <ESC> <C-e> it will expand into $ 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?

From what I can tell the only way to know what $ git f will do when executed is by inspecting git's config beforehand.

like image 726
atommclain Avatar asked Oct 17 '25 19:10

atommclain


1 Answers

Not really, considering git aliases can also include shell expansion definition aliases with positional parameters like "!f() { echo \"$1\" >> .gitignore; }; f"..

And that would be tricky to expand on the shell level.

like image 82
VonC Avatar answered Oct 19 '25 11:10

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!