When you haven’t committed your files and want to switch to another branch for example, you can use stash
in order to save your files. Here are the different ways that stash
can be used:
Save your files with a message
git stash save "Your message here"
List stashes
git stash list
Compare code to the one in the stash
git stash show -p
Drop a particular stash
git stash drop stash@{1}
Apply the last stash and then get rid of it
git stash pop
Apply the last stash and keep it
git stash apply
Apply the first stash
git stash apply stash@{1}
Display the files which the stash interacts with
git stash show
Create a branch from a stash
git stash branch nameOfBranch stash@{stashNumber}