I want to use:
git stash save "Message describing stash"
…but I also want to stash only some of my working directory, using:
git stash --patch
How can I create a stash that both has a message, and includes only selected changes?
Simply combine the two commands together like so:
git stash save --patch "Message describing stash"
This will produce the desired behavior of creating a stash using the hunk-staging interface that also has a message visible in git stash list
.
(Figured this out by just trying it, and in retrospect it feels pretty obvious. Still, something about it was non-obvious enough to cause me to look it up, so I'm leaving this here for anyone else in the same boat. I think maybe seeing save
as a subcommand of stash
rather than an option (like --save
) may have been what threw me off—I'd likely guess that a hypothetical --save
option could be combined with --patch
, but implicitly I think seeing save
without hyphens led me to a question like, "does the --patch
option also work with the the save
subcommand?" And… I seem to have a quick impulse to check with the internet before trying something new in git
. )