Change Git stash message [duplicate]

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?


You can directly edit the messages stored in .git/logs/refs/stash.

I know it's probably not ideal, but should work anyway.


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.


(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 :-)


Not without popping and saving again.


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