Git Stash

gitstash

Git stash is temp storage where we can store some code and when we need that then we can use that code. Let’s take an example to suppose we are working on some code base and we have done some work and after that, we realise we need to do something before this thing so that time we have two option first undo all changes and do that work or second use git stash.

You can save your current working dir into temp storage. Do this:


# save working dir (all uncommitted changes) in a temp storage
git stash save

After you do this, the working tree will be clean. to get it back, do:


# retrieve from stash
git stash pop

To list all your stash, do:


git stash list

About the Author: Pankaj Bisht