When and why would you use git stash?
git stash is used for stashing away changes from git workspace to temporary storage (stash).
Watch the video Git stash - what it is and when to use it where we explain everything.
When you run
git stash without any additional parameters, it does the same as
git stash push
(the push parameter is used by default).
You usually use
git stash when you work on something in your workspace and someone else needs you to skip to something else (critical bug or anything else that deserves attention). If you don't have all the changes finished yet, you shouldn't commit the incomplete changes to the repository. In such case you, you should store your changes to the stash temporarily (which will clean up your workspace), then you can fix the bug and once you are finished with it, you can again restore the original changes from stash using
git pop command.
Related Git job interview questions
What is bare repository in Git?GitSource control Medior
When and why would you use git config command?Git Medior
What is git push good for?Git Medior
What is git pull good for?Git Medior
What do you need to do in order to use Git for your project?Git Medior