git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Elijah Newren <newren@gmail.com>
Date
Aug 15, 2025, 04:04 UTC
Message-ID
<CABPp-BHt80YD9bzWeC+r5qxJ0Vp+zRsJZsKDU_GA39CXmuYe5A@mail.gmail.com>
In-Reply-To
<16220ca65f1ae9883a2fa103e842cf0ffff43236.camel@scientia.org>

On Thu, Aug 14, 2025 at 7:15 PM Christoph Anton Mitterer <calestyo@scientia.org> wrote:

Show 11 quoted lines
>
> Hey.
>
> On Thu, 2025-08-14 at 18:23 -0700, Junio C Hamano wrote:
> > Look for "alias.*" in "git help config".
> >
> >         To avoid
> >       confusion and troubles with script usage, aliases that
> >       hide existing Git commands are ignored.
>
> Can't one add some kind of override for this?

No. And there won't be one in the future either; see e.g. https://lore.kernel.org/git/alpine.DEB.1.00.0903070407480.10279@pacific.mpi-cbg.de/

> Cause AFAIU, my command
> from below would not hide the other commands, or would it?

The documentation you are responding to didn't talk about "other" commands, it talked about "existing" commands. Your alias, meant to invoke `git stash` with different arguments, would hide the existing `git stash` command.

It might also be an infinite loop of sorts, since your `git stash` alias invokes `git stash ...` which is...itself.

And it'd mean that other folks who use git commands in their scripts now can't rely on any git commands doing what their documentation claims.

Show 5 quoted lines
> >       If the alias expansion is prefixed with an exclamation
> >         point, it will be treated as a shell command.
>
> Well I kinda thought that... still wouldn't though if it was detailed
> what exactly happens :-)
Doesn't it detail what happens already?
           If the alias expansion is prefixed with an exclamation
point, it will be treated as a shell command. For example, defining
alias.new = !gitk --all --not
           ORIG_HEAD, the invocation git new is equivalent to running
the shell command gitk --all --not ORIG_HEAD. Note that shell commands
will be executed from the
           top-level directory of a repository, which may not
necessarily be the current directory.  GIT_PREFIX is set as returned
by running git rev-parse --show-prefix
           from the original current directory. See git-rev-parse(1).
What is missing from this explanation?
Previous: Christoph Anton MittererNext: rsbecker@nexbridge.com
Message 4 of 12 in “why can't one alias `git stash`?”
  1. Christoph Anton MittererAug 15, 2025
  2. Junio C HamanoAug 15, 2025
  3. Christoph Anton MittererAug 15, 2025
  4. Elijah NewrenAug 15, 2025
  5. rsbecker@nexbridge.comAug 15, 2025
  6. Christoph Anton MittererAug 16, 2025
  7. Junio C HamanoAug 15, 2025
  8. Christoph Anton MittererAug 16, 2025
  9. Matthias AßhauerAug 16, 2025
  10. Junio C HamanoAug 19, 2025
  11. Christoph Anton MittererAug 19, 2025
  12. Christoph Anton MittererAug 16, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.