I have a stash saved for the future that I want to give a meaningful name. While it's possible to pass a message as argument to git stash save
, is there a way to add a message to an existing stash?

- 86,532
- 28
- 194
- 218
-
1I recognize that this question is older than the flagged duplicate, but that question has better answers. – Michael Jul 12 '17 at 21:29
5 Answers
You can directly edit the messages stored in .git/logs/refs/stash
.
I know it's probably not ideal, but should work anyway.

- 3,939
- 2
- 24
- 17
-
6The fact that that seems to work is incredibly lucky: the message is also stored in the commit message (stashes are represented internally as commits), and you're of course not changing that. – Cascabel Nov 14 '11 at 19:22
-
11This doesn't actually change the commit message (see `git show stash` or `git log --all`), only the entry in the stash reflog. – Zaz Aug 06 '14 at 20:13
Yep, there is a way, you can try this:
git stash store -m "your descriptive message here" stash@{1}
This will create a new Stash named stash@{0}
with the message as above.
This Stash is same as stash@{1}
.
Then you can remove the old stash@{1} above with:
git stash drop stash@{2}
# the stash@{1} has become stash@{2} as a new stash has been created.
NOTE: you cannot do this with stash@{0}: git stash store -m "message here" stash@{0}
will do nothing.

- 1,357
- 12
- 7
-
6
-
Actually I don't know, I tried and it didn't work. So I guess that: If this calls on stash@{1}, then it brings a copy of stash@{1} to top of the stack, so when user call `git stash apply`, he get different result. If this calls on stash@{0}, then later call to `git stash apply` produces in same result. – Ryan Le Oct 30 '14 at 10:29
-
1
-
2
-
3`git stash store` is meant to operate on the commit ref output of `git stash create` i.e. `create` creates the stash commit, `store` writes it to `.git/logs/refs/stash` (i.e. the reflog of `/refs/stash`). By passing `store` an existing commit, I believe it is essentially doing the same thing as the accepted answer, which is to just modify `.git/logs/refs/stash` -- the underlying stash commit stays exactly the same as before. This probably also explains why it doesn't work for `stash@{0}` -- the head of `refs/stash` can't also be in the reflog of `refs/stash` (or something similar anyway). – Raman Aug 26 '19 at 21:25
(Expanding on manojlds's answer.) The simplest thing to attach a message is indeed to un-stash and re-stash with a message, there is a git stash branch
command that will help you doing this.
git stash branch tmp-add-stash-message
git stash save "Your stash message"
The only drawback is that this stash now appears to originate from the tmp-add-stash-message
branch. Afterwards, you can checkout another branch and delete this temporary branch.
Of course, this assumes that your working copy is clean, otherwise you can stash the current changes :-)

- 25,056
- 14
- 120
- 217
Not without popping and saving again.

- 290,304
- 63
- 469
- 417
-
3Not that simple if your stashes are across various branch as "popping and saving again" would apply the stashed commit to the current branch (which could fail on merge). If you find yourself with a long list of sashes you probably need to make better use of branching. – i3ensays Sep 09 '13 at 17:01
-
3@RobertDailey well if you popped the stash and there are merge conflicts, you will very much be pooping yourself. – David T. May 08 '14 at 21:12
-
1
Here's some commands to help you pop and save again as @manojlds suggests:
git stash #save what you have uncommitted to stash@{0}
git stash pop stash@{1} #or another <stash> you want to change the message on
# only if necessary, fix up any conflicts, git reset, and git stash drop stash@{1}
git stash save "new message"
git pop stash@{1} #get back to where you were if you had uncommitted changes to begin with

- 5,653
- 2
- 44
- 65