← Back to Mission Control

Cargo Hold

11 min read

Git Stash

Mission Phase 27 • Difficulty: Intermediate

Temporarily Storing Changes

Stash saves your uncommitted changes temporarily, letting you switch contexts without committing half-finished work.

Basic Stash

git stash

Saves all tracked changes and reverts working directory to last commit.

Stash with Message

git stash save "Work in progress on sensors"

Include Untracked Files

git stash -u

List Stashes

git stash list

Output:

stash@{0}: WIP on main: abc123 Latest commit
stash@{1}: On feature: Work in progress on sensors

Apply Stash

git stash apply        # Apply most recent
git stash apply stash@{1}  # Apply specific stash

Keeps stash in list after applying.

Pop Stash

git stash pop

Applies and removes stash from list.

Drop Stash

git stash drop stash@{0}

Clear All Stashes

git stash clear

View Stash Contents

git stash show -p stash@{0}

Common Use Cases

Workflow Example

# Working on feature
git stash

# Switch to fix urgent bug
git switch main
# Fix bug, commit, push

# Return to feature
git switch feature-branch
git stash pop

Next: Quick Commands

Stash is your temporary storage. Next, learn aliases to speed up your workflow with custom shortcuts.