Git is arguably the most versatile version control system around and one cannot resist falling in love with this awesome piece of code every time you use it.
One of the lesser known features in Git, especially for individual developers/teams who have recently migrated from other tools is the “stash” command.
You might often find yourself in situation when you aren’t yet ready to commit your code, you would like to view the last commit without trashing the existing code. You could also be in situation when you want keep your local changes without committing and then swap to do something else.
This is where the stash comes into the picture. Stash creates a backup of your current staged and unstaged changes, and returns your branch to the last commit. To stash your changes, you use the stash command.
When you are ready to go back to your stashed changes, you can use the ‘git stash apply‘ command. This would take your latest stashed changes and apply it to the branch.
git stash apply.
Finally you could delete your stashed changes by using the git stash drop command.
git stash drop.
This would remove your last set of stashed changes.