git stash
Put uncommitted edits aside for a while and bring them back later
What it does
git stash moves your uncommitted changes into a separate store and brings the files back to the last commit. You need it when you must switch branches or run git pull right now, but your current work is not ready to commit.
git stash pop brings back the latest stashed edits and removes them from the store. You can stash several times; git stash list shows them all. New, untracked files are not stashed by default: add -u for them.
Syntax
git stash
git stash -u
git stash list
git stash popExamples
Temporarily put away uncommitted changes
git stashsame as:
git stash pushstash— hide changes on a stack
Bring back the most recently stashed changes
git stash popstash— temporary storage for changespop— take them out and remove from the stack
Related commands
- git switch — Switch to another branch, or create a new one and switch to it
- git pull — Download changes from the server and merge them into the current branch
- git commit — Save the staged changes to history as a new commit