What does git stash do and when should I use it?
Stashing takes your uncommitted changes, saves them aside, and returns the working tree to a clean state matching the last commit. The changes are not lost; they are stored on a stack you can reapply later.
The usual reason is needing a clean tree in the middle of unfinished work. Switching branches to review someone else's change, pulling updates that touch files you have edited, or checking whether a bug exists on the main branch all require the tree to be clean or nearly so.
Applying a stash comes in two forms and the difference matters. Popping applies it and removes it from the stack. Applying leaves it on the stack, which is safer when reapplying to a different branch, because a conflict during a pop can leave you in an awkward state with the stash already consumed.
Several things surprise people.
Untracked files are not stashed by default. A newly created file stays in the working tree, which is usually fine but can be confusing when it then conflicts with something on the branch you switch to. An option includes them explicitly.
Stashes are not tied to a branch. Popping applies wherever you are, which is sometimes what you want and sometimes produces a mess.
The stack is easy to forget. Stashes accumulate silently and are identified by index, so a stash from three weeks ago is easy to apply by accident. Listing them and giving each a message when stashing makes this manageable.
For anything you might want in more than a few hours, a work-in-progress commit on a branch is more durable and more visible than a stash. Stashing suits genuinely short interruptions.