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

why can't one alias `git stash`?

From
Christoph Anton Mitterer <calestyo@scientia.org>
Date
Aug 15, 2025, 00:33 UTC
Message-ID
<a24d0d237b9f57535c768da4c00d72bad68cf411.camel@scientia.org>
Hey.

Personally, I've always disliked that `git stash` already does the `push` and would have much more preferred it, if it did a `stash list`.

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

Any idea why that doesn't work?

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?

Are these functions executed in a separate shell execution environment (or could I accidentally override a function from some git shell script)?

Is there any sanitisation of the environment that the shell gets (or does it simply get whatever the user has)? I mean a badly set IFS or similar could easily cause troubles.

Thanks, Chris.

Next: Junio C Hamano
Message 1 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.