gitgit-stash

How can I rename a git stash?


I have a stash with an incorrect name. I would like to fix the name so it's accurate.

How can I rename a stash?


Solution

  • Let's assume your stash list looks like this:

    $ git stash list
    stash@{0}: WIP on master: Add some very important feature 
    stash@{1}: WIP on master: Fix some silly bug
    

    First, you must remove stash entry which you want to rename:

    $ git stash drop stash@{1}
    Dropped stash@{1} (af8fdeee49a03d1b4609f294635e7f0d622e03db)
    

    Now just add it again with new message using sha of commit returned after dropping:

    $ git stash store -m "Very descriptive message" af8fdeee49a03d1b4609f294635e7f0d622e03db
    

    And that's it:

    $ git stash list
    stash@{0}: Very descriptive message
    stash@{1}: WIP on master: Add some very important feature
    

    This solution requires git 1.8.4 or later, and yes, it works with dirty working directory too.