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 pop can cause conflicts if the stashed changes overlap
  • New untracked files need the -u flag: git stash -u
  • git stash clear cannot be undone — use with caution

After stashing, use Git Branch Basics to switch branches and come back when ready.

  • Fiverr - Find freelance developers and tech experts