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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 15, 2025, 15:27 UTC
Message-ID
<xmqqjz34txjg.fsf@gitster.g>
In-Reply-To
<CABPp-BHt80YD9bzWeC+r5qxJ0Vp+zRsJZsKDU_GA39CXmuYe5A@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
> 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.
Correct.
> It might also be an infinite loop of sorts, since your `git stash`
> alias invokes `git stash ...` which is...itself.
True.  But we do not do a very good job preventing this to happen.
    $ git -c alias.loop='loop foo' loop foo
    fatal: recursive alias: loop
    $ git -c alias.loop='!git loop foo' alias foo ;# does not come back
    ^C

To be honest, I do not offhand see a foolproof way to "fix" the latter.

> 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.

It is true that it would break common expectations for script writers (to help other Git users) and those who help other Git users at their keyboards if we allowed to alias the basic command away and to change its behaviour radically. But with so many configuration variable to alter behaviour for Porcelain commands, I am not sure how much it is helping the latter helpers these days. For the former helpers, those who write their scripts with Porcelain commands are beyond salvation X-<.

Thanks.
Previous: Christoph Anton MittererNext: Christoph Anton Mitterer
Message 7 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.