threads / discuss / 59975

Possible typo in git stash doc page

Subject: Possible typo in git stash doc page

## tl;dr

2 messages between Jul 12, 2023 and Jul 12, 2023.

replies: 1people: 2as markdown or json

Manuel Ricci· Jul 12, 2023, 15:01 UTC · lore
Hi,

In the doc page about git stash, specifically where there're the details about git stash push https://git-scm.com/docs/git-stash#Documentation/git-stash.txt-push-p--patch-S--staged-k--no-keep-index-u--include-untracked-a--all-q--quiet-m--messageltmessagegt--pathspec-from-fileltfilegt--pathspec-file-nul--ltpathspecgt82308203

There's a reference about --staged or -S. I tried to execute the command with that flag and the output is like this one:

error: unknown switch `S'
usage: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
          [-u|--include-untracked] [-a|--all] [-m|--message <message>]
          [--] [<pathspec>...]]
    -k, --keep-index      keep index
    -p, --patch           stash in patch mode
    -q, --quiet           quiet mode
    -u, --include-untracked
                          include untracked files in stash
    -a, --all             include ignore files
    -m, --message <message>
                          stash message
Even if the flag is --staged
error: unknown option `staged'
usage: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
          [-u|--include-untracked] [-a|--all] [-m|--message <message>]
          [--] [<pathspec>...]]
    -k, --keep-index      keep index
    -p, --patch           stash in patch mode
    -q, --quiet           quiet mode
    -u, --include-untracked
                          include untracked files in stash
    -a, --all             include ignore files
    -m, --message <message>
                          stash message

At the start of the same page, --staged is not present in the push arguments, so I think that is a typo.

Have a good day
Manuel
Junio C Hamano· Jul 12, 2023, 15:49 UTC · re: Manuel Ricci · lore

Re: Possible typo in git stash doc page

Manuel Ricci <manuelricciwc@gmail.com> writes:
Show 15 quoted lines
> In the doc page about git stash, specifically where there're the
> details about git stash push
> https://git-scm.com/docs/git-stash#Documentation/git-stash.txt-push-p--patch-S--staged-k--no-keep-index-u--include-untracked-a--all-q--quiet-m--messageltmessagegt--pathspec-from-fileltfilegt--pathspec-file-nul--ltpathspecgt82308203
>
> There's a reference about --staged or -S. I tried to execute the
> command with that flag and the output is like this one:
>
> error: unknown switch `S'
> usage: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
> ...
> Even if the flag is --staged
>
> error: unknown option `staged'
> usage: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
> ...

This is not a very reproducibly-helpful bug report. Re-reading the above, we do not even learn what exact command you typed, and what the state the repository you saw the error message was in.

In a random repository I happened to be in, that had Makefile tracked, I did this:

    $ git version
    git version 2.41.0-327-gaa9166bcc0
    $ git stash -S
    No local changes to save.
    $ echo "# junk" >>Makefile
    $ git stash -S
    No staged changes.
    $ git add Makefile
    $ git stash -S
    Saved working directory and index state WIP on ...

The commands in various state seem to be working as expected. It would complain when there is nothing to save, it complains differently when there is something to save but the change is not in the index, and it reports what it did when it did save.

The option was implemented with 41a28eb6 (stash: implement '--staged' option for 'push' and 'save', 2021-10-18) that first appeared in Git 2.35, so it is possible that the version of Git you are using is too old to have it, but from your bug report we cannot tell if that is the case.

HTH?

← back to recent threads