Stashing Your Changes in Git
This little snippet of information will show you how to use the git stash command to stash your changes in git.
Published on:November 20, 2013
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.
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.
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.
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.
git stash apply stash@{1}