Stashing Codes Changes in Git

Stashing Codes Changes in Git

Using version control, is best to commit your code in small, discrete chunks rather than making large commits. However, 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. Let’s run through this with me.

Stash the Code

1
git stash

Reapply the Changes You Sent to the Stash Type
What if you want to reapply your changes? Use git stash apply to reapply all the changes you stashed away with git stash.

1
git stash apply

List All of the Stashes You’ve Made Type
Git stash supports stashing multiple times. To see a list of all the code you’ve stashed, use git stash list. The git stash list will show you a list of all the stashes you’ve made.

1
git stash list

Stash Apply From the Earlier List
If the first stash is named stash@{1}, you can type git stash apply stash@{1} to apply the changes from that stash.

1
git stash apply stash@{1}

So far so good, That’s it! See ya! :)