Search code examples
gitgit-stash

Git: How to store 'git stash' Data


I had some particular uncommitted changes in my development branch and I stashed them using git stash command, and I am re applying those stashed changes using git pop command.

But this specific state I want to preserve (If possible then may me in some text format).

Because there are many times I have some uncommitted changes which are not particular I am doing that just sake for branch changing activity so my particular stashed changes get overlapped(removed). So I want to preserve that particular stash.

Is there any chance I can preserve the specific stashed changes in some file if possible?


Solution

  • Because there are many times I have some uncommitted changes which are not particular I am doing that just sake for branch changing activity so my particular stashed changes get overlapped(removed). So I want to preserve that particular stash.

    You can have Multiple stashes

    git stash list
    
    stash@{0}: WIP on master: 686b55d Add wolves.
    stash@{1}: WIP on gerbils: b2bdead Add dogs.
    stash@{2}: WIP on gerbils: b2bdead Add dogs.
    

    Stash names are shown in the list. And gives you the list of stashs which are saved in stash's stack.

    $ git stash apply stash@{1}
    # On branch gerbils
    # Changes not staged for commit:
    #
    # modified: index.html
    

    stash@{0} is the default when applying; specify the stash name to apply a different one

    git stash apply <stash-name>
    

    Hope this help you !!!