Search code examples
gitnetbeans-8git-stash

Automatically delete existing git stash when unstashing


I started using git. As I work with different branch between which I sometimes like to change without committing current modifications, I'm using the stash function. This works like a charm. My only concern is, that after I unstash the stash still keeps existing. Doing this a couple times, it pollutes the branch. Is there a way to automatically remove a stash when unstashing it?

Update

So I downloaded the source package of netbeans and customized the git module. The only thing to change was a hard coded boolean from false to true for the apply command of a stash, as the whole drop mechanism is already implemented. I loaded the customized module into my netbeans instance and now, when I unstash, the stash automatically gets dropped.


Solution

  • You should run:

    git stash pop
    

    See the man page:

    pop [--index] [-q|--quiet] [<stash>]

    Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of git stash save. The working directory must match the index.

    If you don't want to remove the state, you should use:

    git stash apply
    

    See here for details.