Frequently Asked Question

What does git stash do?

git stash is the "I need a clean working tree right now, but I am not ready to commit" command. It records the current state of your tracked, modified files (optionally also untracked ones with -u) onto a hidden stack, then resets the working tree to match HEAD. You can now switch branches, pull updates, or do anything else that requires a clean slate, and bring your changes back later with git stash pop (apply and drop) or git stash apply (apply but keep on the stack).

git stash list shows the current stack. Each entry has a message, by default "WIP on branch: last-commit", but git stash push -m "fixing login bug" lets you tag the entry meaningfully, which matters once you have more than two or three stashes. The stash is local-only and is not pushed to remotes; it is a personal scratch pad. Long-lived stashes are an anti-pattern, since you will inevitably forget what is in them. Use stash for minutes-to-hours, branches for anything longer.

Further reading and video