git stash

git stash temporarily shelves your uncommitted changes so you can switch tasks with a clean working directory, then bring them back later with git stash pop.

Git & DevOps

Stashing is handy when you're mid-change but need to switch branches or pull updates without committing half-finished work. Git saves the changes on a stack you can reapply anytime.

git stash pop reapplies the most recent stash and removes it from the stack, while git stash apply reapplies it but keeps it saved.

Syntax

git stash
git stash pop

Examples

Bash

git stash
git switch main
git stash pop

Output:

Saved working directory and index state WIP on feature-login
On branch feature-login
Dropped refs/stash@{0}

Learn it in a lesson

See also

Back to the Dictionary