CPCODELAB
Git & GitHub

Stashing Work in Progress

6 min read

Saving Uncommitted Work Temporarily

git stash saves your working directory and staging area changes to a temporary stack and reverts to a clean state. This is useful when you need to switch branches urgently without committing half-finished work.

bash
git stash                        # save current changes
git stash push -m 'wip: login form validation'
git stash list                   # view all stashes
git stash pop                    # apply the latest stash and remove it
git stash apply stash@{2}        # apply a specific stash without removing it
git stash drop stash@{0}         # delete a specific stash
git stash clear                  # delete all stashes

By default, git stash only stashes tracked files. Pass -u to also stash untracked files, or -a to include ignored files too.

Stashes are local — they do not push to the remote. If you need to share unfinished work, commit with a wip: prefix and push, then clean it up later with interactive rebase.

Ready to test yourself?
Practice Git & GitHub— quiz & coding exercises