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 cleanAll lessons in this course
- Interactive Rebase and Amending
- Stashing and Cherry-picking Changes
- Reflog for Recovery
- Bisect: Hunting Down Bad Commits