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

Re: Git reference git stash

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2026, 21:50 UTC
Message-ID
<xmqqv7f8y6ev.fsf@gitster.g>
In-Reply-To
<aarHnK-oPHlx_hCw@Eriks-MacBook-Pro.local>
erik88 <erik88@gmail.com> writes:
Show 11 quoted lines
> Pretty sure git stash push is the only one which does pathspec
>
>     git stash -h
>     usage: git stash list [<log-options>]
>        ...
>        or: git stash [push [-p | --patch] [-S | --staged] [-k | --[no-]
>                      [-u | --include-untracked] [-a | --all] [(-m | --m
>                      [--pathspec-from-file=<file> [--pathspec-file-nul]
>                      [--] [<pathspec>...]]
>
> and pretty sure it's relative.

In a very early days of Git, I suspect there were, but in modern version with ":/" (or :(top)" pathspec magic, I do not think of a need for any command (unless it cannot work from anywhere except for the top level of the working tree for some reason) to insist taking pathspec from the top, not relative to the directory where the user is at. It would break the <TAB>-completion if anything insists that the pathspec must be relative to the top-level.

It may be a very good exercise (this can be done even by somebody relatively new to the community, I think) to see if anything still insists <pathspec> from the top. And change the documentation of the pathspec to say "unless specifically spelled out in each command's documentation, pathspec elements are taken as relative to the current directory" or something.

Show 6 quoted lines
> Sadly, git stash list does not allow a pathspec, despite the
> [<log-options>]. But if you want you can do
>
>     git log stash [<log-options>] [--] [<pathspec>]
>
> instead, which is handy sometimes.
Previous: erik88
Message 5 of 5 in “Git reference git stash”
  1. Aron SigfridssonMar 5, 2026
  2. Mirko FainaMar 6, 2026
  3. Mirko FainaMar 6, 2026
  4. erik88Mar 6, 2026
  5. Junio C HamanoMar 6, 2026

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.