There will be times when you would like to temporarily save some changes, but you are not ready to commit them to a branch yet. For example you could be working on a task, but in the middle of it you get a call that there is problem with the production environment and a "hotfix" is required.
That would require you to checkout an old version to reproduce the problem. Any changes related to the task you are working on would get in the way.
To solve this issue you can “stash” your changes and bring them back later:
$ git stash
This will add your changes to the stash stack. You will no longer see your changes when you execute the status command and they will not get in the way. Allowing you to checkout any branch or commit state.
When you are done with the "hotfix" or other problem that required you to stash your changes, you can execute the following command to get the changes back:
$ git stash apply
It is usually best to this before making new changes to reduce the risk of having to resolve a new merge conflict.