Reputation: 1971
In the git stash
documentation, there is this paragraph:
For quickly making a snapshot, you can omit "push". In this mode, non-option arguments are not allowed to prevent a misspelled subcommand from making an unwanted stash entry. The two exceptions to this are stash -p which acts as alias for stash push -p and pathspecs, which are allowed after a double hyphen -- for disambiguation.
What exactly does the highlighted sentence mean?
The only non-option arguments that I think can be used are <message>
and <pathspec>...
.
Does it mean that if one writes the command git stash -m"message"
, git may think that the user misspelled the word stash
, but it executes the command (git stash push
) anyway?
Thank you.
Upvotes: 2
Views: 124
Reputation: 21918
To my understanding, it's linked to the typical behaviour of git stash save
.
If you do
git stash save whatever you want
then every argument ('whatever', 'you', and 'want') will be taken as a whole to compose the stash message. (note : stash save
is deprecated)
Now, as git stash push
allows omitting push
, the statement you quote in bold is making "clear" (obviously, not enough) that the behaviour we just saw about git stash save
does NOT apply. Other non-option arguments are not allowed here.
In short, an example of what we cannot do :
git stash whatever I want
where push
would be implied after stash
.
Or more specifically (to address the "misspelling" part) :
# next command will create a new branch with the last stashed content
git stash branch myNewBranch
# and the next WOULD HAVE created a new stash entry with message "brnach myNewBranch"
# if not for the part you quoted in bold
git stash brnach myNewBranch
Edit after comments : But then this last misspelled line will just be rejected in error instead of stashing anything inadvertantly.
Upvotes: 2