0PricingLogin
Git Advanced: Monorepo, Submodules & Workflows · Lesson

Stashing and Cherry-picking Changes

Master `git stash` to temporarily save changes and `git cherry-pick` to apply specific commits across branches.

Why Use Git Stash?

Mid-feature and an urgent bug fix lands? git stash temporarily shelves your uncommitted changes so you can switch branches without committing half-done work.

Saving Your Changes Temporarily

Run git stash to save your modified and staged changes, then Git resets your working directory to a clean HEAD. Your work is safely tucked away.

git status
# On branch feature-x
# Changes to be committed:
#   new file:   new_feature.txt
# Changes not staged for commit:
#   modified:   index.html

git stash
# Saved working directory and index state WIP on feature-x: ...
# HEAD is now at ...

git status
# On branch feature-x
# nothing to commit, working tree clean

All lessons in this course

  1. Interactive Rebase and Amending
  2. Stashing and Cherry-picking Changes
  3. Reflog for Recovery
  4. Bisect: Hunting Down Bad Commits
← Back to Git Advanced: Monorepo, Submodules & Workflows