Subject: Re: why can't one alias `git stash`?

From: Junio C Hamano <[email-masked]>
Date: Thu, 14 Aug 2025 18:23:25 -0700

Christoph Anton Mitterer <[email-masked]> writes:

> So I tried to solve this via an alias like:
> [alias]
>         stash = "!c(){ if [ \"$#\" -eq 0 ]; then git stash list; else git stash \"$@\"; fi; }; c"
>
> which seems however to be ignored when the alias name is "stash" (it
> works as it should when I use e.g. foo = ...).

Look for "alias.*" in "git help config".

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

> Also when using such shell functions seems to be not extensively
> documented (or I didn't find it)... the example in git-config gives the
> "!c()..." syntax but doesn't seem to tell what the ! is for?

	If the alias expansion is prefixed with an exclamation
        point, it will be treated as a shell command.