When using version control, is is best to commit your code in small, discrete chunks rather than making large commits. However, in reality that doesn't always happen. What happens when you are working on a large change, and your boss comes to you and tells you they need an urgent bug fixed? With the git stash command you can quickly and easily store your code away and recall it for later use.

To stash your code, simply type:

git stash

What if you want to re apply your changes? Simple use the git stash apply command. This command will reapply all the changes you stashed away with git stash.

To reapply the changes you sent to the stash type:

git stash apply

Git stash even supports stashing multiple times. To see a list of all the code you've stashed, simply use git stash list. The git stash list will show you a list of all the stashes you've made.

To list all of the stashes you've made type:

git stash list

From there, Simply type git stash apply and the name of your stash to apply the changes from that stash. For example, if the first stash is named stash@{1}, you can type git stash apply stash@{1} to apply the changes from that stash.

Example git stash apply from the earlier list command:

git stash apply stash@{1}