Temporarily Stashing Work
git stash temporarily saves working-tree and staging changes so you can switch context without committing incomplete work. A stash is stored in Git's stash references and can later be applied or popped.
Modern Git also supports git stash push -m for descriptive stash messages and git stash push -u to include untracked files.
Stash and Restore Work
git stash push -m "WIP login validation"
git switch main
git switch feature/login
git stash list
git stash pop💡
stash push saves the changes. stash list shows saved entries, while stash pop applies the latest stash and removes it if successful.Key Takeaways
- Stash is useful for temporarily incomplete work.
- Use descriptive stash messages when maintaining multiple entries.
- Stashes can conflict when applied to changed code.
Knowledge Check
What is the primary purpose of `git stash`?