git stash
git stash: temporarily save the changes in your working directory for later use, while reverting your working directory to a clean state (the state of the last commit).
When you run git stash, Git takes the edits you’ve made to tracked files (and any changes you’ve staged) and puts them in temporary storage called stash. Your work files are then restored to how they looked in the last commit.
This is useful when you need to pause what you’re doing—maybe to switch branches, pull new updates, or try something risky—without losing your progress. By default, Git leaves untracked files alone, but you can choose to include them.
The stash is like a stack of cards. You can push new changes onto the top of the stack and pop them off when you need them again. In most cases you'll use git stash (which is the same as git stash push) to create a new stash, and later use git stash pop to reapply it, which also removes it from the stash list.
Each stash gets an identifier like stash@{0}, where 0 is the most recent entry. You can
list, apply, inspect, drop, or clear stashes at any time.
Examples
Temporarily save your current changes and clean your working directory:
git stashSame as:
git stash pushApply the most recent stash and remove it from the stash list:
git stash popAdd a descriptive message to your stash for easier identification later:
git stash push -m "WIP: responsive header"Include untracked files in the stash:
git stash push -uReview what you have stashed and inspect the diff of a specific entry:
git stash listgit stash show -p stash@{0}
Reapply a stash without deleting it, restoring both working tree and staged changes:
git stash apply --index stash@{1}This may be useful if you want to apply the stash in multiple branches or keep it for future use.
Remove a specific stash entry:
git stash drop stash@{0}Clear all stashes when they are no longer needed:
git stash clear