AcademyTimeline Architect: Mastering the Time MachineProtocol 7: Deep Chronology

Lesson 1: The Cherry Picker (Stash & Cherry-Pick)

Sometimes you're in the middle of cooking dinner when the fire alarm goes off. You need to save your half-cooked meal, handle the emergency, and come back to finish cooking. That's what git stash and git cherry-pick are for.

git stash — The Emergency Save

You're working on a feature when an urgent bug report comes in. You can't commit half-finished code, but you can't lose it either. Stash saves your changes in a temporary pocket.

git stash                   # Save current changes
git stash save "WIP login"  # Save with a description

After stashing, your working directory is clean — as if you never made those changes. Now you can switch branches, fix the bug, and come back.

Managing Your Stash

git stash list               # See all stashed changes
stash@{0}: WIP on feature: a1b2c3d WIP login
stash@{1}: WIP on main: e4f5g6h Fix typo
git stash pop                # Restore most recent stash & remove it
git stash apply              # Restore most recent stash & keep it
git stash drop stash@{1}     # Delete a specific stash
git stash clear              # Delete ALL stashes

git cherry-pick — The Surgical Transplant

What if you want just one specific commit from another branch, without merging the entire branch?

git cherry-pick abc123

This copies commit abc123 and applies it to your current branch as a new commit.

When to Cherry-Pick

| Scenario | Example | |----------|---------| | Hotfix backport | Apply a fix from main to release/v1.0 | | Selective feature | Grab one commit from a feature branch | | Undo a revert | Cherry-pick the original commit back |

Cherry-Pick Workflow

# 1. Find the commit hash you want
git log --oneline feature/payments
# f6e5d4c Add payment validation
# a1b2c3d Add payment form

# 2. Switch to your target branch
git checkout main

# 3. Cherry-pick the specific commit
git cherry-pick f6e5d4c

# 4. The commit is now on main!
git log --oneline
# x9y8z7w Add payment validation  (cherry-picked)
booting...

Mission Objective

Practice emergency operations:

  1. Emergency save: Run git stash to pocket your current changes.
  2. Check the pocket: Run git stash list to see what's stashed.
  3. Restore: Run git stash pop to bring your changes back.

Mission Control

Stash your current changes

Expected Command

git stash

List all stashed changes

Restore your stashed changes