REFERENCE · GIT BASICS

Git stash explained

Park unfinished work, then bring it back carefully.

Save the current tracked changes

Stash records working-tree and index changes and returns them toward HEAD. It is local, not a remote backup. Use a message so you can recognize the work later.

git stash push -m "menu work in progress"
git stash list

Untracked files need an option

By default stash does not include untracked files. -u includes them; -a also includes ignored files. Check the files first, especially generated output and sensitive local files.

git status
git stash push -u -m "include new files"

Apply and pop differ

Apply restores changes and keeps the stash entry. Pop restores and, on success, removes it. When conflicts prevent a successful pop, Git keeps the entry so you can recover.

git stash apply
# Alternative, not an additional required step:
git stash pop

Inspect before dropping

Stash can conflict when the target files have changed. Inspect list and show, resolve conflicts deliberately, and drop only an entry whose work you no longer need. Do not use clear as a routine habit.

git stash show -p

Quick check

Which restores work while keeping the entry?

Choose an answer.

Sources and scope

Command blocks are syntax examples checked against official documentation, not fabricated terminal output. Replace uppercase placeholders with your actual names and inspect status before commands that change work.

git-stash ·

All references · Course map

Git, Visually · Reference