The hidden gem:
git stashdoes way more than you think β partial stashes, named stashes, stash branches, and stash-based workflows.
Most people know git stash and git stash pop. That's white-belt stash. Here's the black-belt stuff.
# Stash with a descriptive message
git stash push -m "WIP: half-done search feature"
git stash push -m "experiment: new task format"
# Now your stash list is readable:
git stash list
# stash@{0}: On main: experiment: new task format
# stash@{1}: On main: WIP: half-done search featureStash specific files or even specific hunks, not everything:
# Stash only specific files
git stash push -m "just the model changes" -- tasks.py
# Interactive: choose which hunks to stash (like git add -p)
git stash push -p -m "partial work"-p (patch mode) lets you stash individual chunks of changes. Everything else stays in your working directory.
# Include untracked files (new files not yet added)
git stash push --include-untracked -m "with new files"
# Short form:
git stash push -u -m "with new files"
# Include EVERYTHING, even .gitignore'd files
git stash push --all -m "nuclear stash"Applied a stash to the wrong branch? Or your stash conflicts with current work?
# Create a new branch from a stash
git stash branch new-feature-branch stash@{0}This creates a new branch from the commit where the stash was made, applies the stash, and drops it. Zero conflicts guaranteed.
# See what's in a stash
git stash show stash@{0}
# See the full diff
git stash show -p stash@{0}
# See the stat summary
git stash show --stat stash@{0}# pop = apply + drop (removes from stash list)
git stash pop
# apply = apply but keep in stash list (safer)
git stash apply stash@{0}
# drop a specific stash manually
git stash drop stash@{1}Pro tip: Use apply instead of pop until you've verified the apply worked. Then drop manually.
bash episodes/demos/05-stash-kungfu-demo.sh