Sometimes, when we are making changes to a project in git, we realize we suddenly need to revert back to the last clean working directory version of our project - that means the version with no local changes applied. For example, suppose you had recently cloned or pulled a version of a project to your local computer and had made some local changes to three files. To revert your project to the version you cloned or pulled, you can run the following command: git stash This will both , by stashing them somewhere safe, and also revert back to a clean version of your project which you can then go about saving, editing, or doing whatever you like with. save your changes Most people are aware that they can do this using , but there are a few other things lets us do too. When it comes to , there are a few really useful commands you should be aware of: git stash git stash git stash git stash list git stash show git stash apply git stash pop git stash push git stash clear git stash drop Listing or Showing All Git Stash Changes While we can easily use to clean up our working tree, we can also see all stashes using the following command: git stash git stash list Interestingly, this will show multiple stashes that have occurred in the past. Git, therefore, stores all stashes, in case you want to retrieve them in the future. For example, here is a project with many stashes, after running : git stash list stash@{0}: WIP on master: abf89a3 feat-ui: updated look and feel stash@{1}: WIP on master: 39329d5 feat-ui: Updated CSS Quiz Button stash@{2}: WIP on master: 46bc7aa feat-ui: Bug fix on article API stash@{3}: WIP on master: 5dafc53 feat-ui: Fixed issue with secondary-navigation overflow All stashes are stored in your file within the folder. A more detailed view of the most recent can also be viewed with : ref/stash .git git stash git stash show common.js | 405 +-------------------------------------------------------- public/quiz.js | 267 +------------------------------------ While this is fine for some, an even more detailed view including code level changes can be shown by running the following command: git stash show -p also has a few other useful options: git stash show or , to show untracked files in that are in the stash, i.e., -u --include-untracked git show git stash show -u , to show only untracked files in that are in the stash, i.e., --only-untracked git show git stash show --only-untracked Recovering a Git Stash With Apply or Pop While knowing what has been stashed is in itself useful, it is also quite useful to be able to recover a stash. To recover your most recent stash of code, you can run the following command: git stash apply If you're like me, though, and you have tonnes of unused stashes, sometimes it's also useful to recover a previous stash, such as , or , like in the list we saw before. In these cases, we simply list the number of the stash after the command. stash@{3} stash@{25} For example, to recover , we would run the following: stash@{25} git stash apply 25 As you'd expect, if you've modified files, and then try to run on top, you may run into merge conflicts. So, make sure those are taken care of before running this command. git stash apply git stash apply versus git stash pop Just now, we've used to recover a stash of code. This will take our stashed code, and apply it on top of our working tree. It will also leave the stashed copy of your code still in your list of stashed codes - so you won't lose it. git stash apply If you want to recover stashed code and remove that stash from your stash list, you have to use instead: pop git stash pop Turning Your Stash Into a Branch Another useful thing which does (which is under-utilized) is that it allows us to make a new branch from our stashed code. If you have some stashed code, you can take your current project with the changes in it, apply your stashed code on top, and then make a new branch named as you like. git stash For example, the following will create a branch called : new-code git stash branch new-code Other Ways to Save Your Stash and Git Stash Push While we've covered how you can use to stash the most recent code, you may also see the following command in the wild: git stash git stash push This command is actually the same as but can be a little confusing if you aren't aware of that. As well as this, and come with a number of useful options, should you wish to use them: git stash git stash git stash push or , will save the whole working tree to the stash, i.e., -a --all git stash push -a or , will save only staged changes added using , i.e., -S --staged git add git stash push -S or , will allow you to go through each change and selectively decide whether you want to stash it, i.e. -p --patch git stash -p or , to save all untracked files along with your stash, i.e., -u --include-untracked git stash push -u Suppressing messages with git stash As a side note, at this point, it makes sense to mention that pretty much all commands come with the option, which suppresses any messages or errors: git stash -q git stash apply -q Removing Your Stash Finally, sometimes you want to remove your entire stash. This is a little dangerous, so use it with , but if you want to, all you have to run is: caution git stash clear If you don't want to do something like that, but still want to remove a specific stashed item, you can run to drop the most recently stashed entry, or to drop the stash listed as in your result. git stash drop git stash drop 25 stash@{25} git stash list