Basic Commands
git stash # Stash changes
git stash list # View stash list
git stash pop # Restore latest stash and delete it
git stash apply # Restore latest stash (keep it in list)
git stash drop # Delete latest stash
git stash clear # Delete all stashes
Common Workflow
# Urgent fix needed while working on a feature
git stash
git switch hotfix
# Make and commit the fix
git switch main
git stash pop
Common Pitfalls
git stash popcan cause conflicts if the stashed changes overlap- New untracked files need the
-uflag:git stash -u git stash clearcannot be undone — use with caution
After stashing, use Git Branch Basics to switch branches and come back when ready.
Related Posts
- Git Branch Basics: Create and Switch Branches
- How to Undo a Git Commit
- How to Resolve Merge Conflicts After git pull
- How to View Commit History with git log
Recommended Services
- Fiverr - Find freelance developers and tech experts