Git & stash - bradsorour/notes GitHub Wiki
Stashing
Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time. This is useful when you want to switch branches for a bit to work on something else. The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later.
To push a new stash onto your stack run
$ git stash
Your working directly is now clean. At this point, you can easily switch branches and do work elsewhere; your changes are stored on your stack. To see which stashes you’ve stored, you can use
$ git stash list
You can reapply the changes you just stashed by using the command
$ git stash apply
If you want to apply one of the older stashes in the list, you can specify it by naming it, like this:
$ git stash apply stash@{2}
If you don’t specify a stash, Git assumes the most recent stash and tries to apply it.
You can also run $ git stash pop to apply the stash and then immediately drop it from your stack.
To delete all your git stashes at once:
$ git stash clear
git stash show
To see a summary of changes to a file, but will not show the diff, use the command:
$ git stash show
To check the diff against a selected stash:
$ git stash show -p stash@{0}
git diff
A common command which is used to show changes between commits, commit and working tree, etc.
To get difference between top most stash stash@{0} and master branch:
$ git diff stash@{0} master
git stash drop
To remove a stash run the command:
$ git stash drop stash@{0}