Keep in mind when modifying or adding new files on different branches, if there isn't a commit, those changes will “propagate” to other branches if you switch. When you’re working on a branch and you're not quite finished but need to move onto another branch, git stash will take all the changes in your working tree and index and “stashes.” You'll run git stash apply to “unstash” the changes. Keep in mind it is applied to the current branch.
When you perform a stash, it's a merge commit. Git keeps track of the state of the index/staging-area and the working tree. Keep in mind that the index and working tree could contain changes to the same file. So essentially there are two commits when you stash. With these two commits, Git is able to “unstash” your changes.
# This command will run "apply" and a "drop" to keep your stash list clean. git stash pop
git init Initialized empty Git repository in /home/john/Projects/git-stash-test/.git/ echo "bacon" > bacon.txt git add bacon.txt git commit -m "initial commit" [master (root-commit) 6d2649a] initial commit 1 file changed, 1 insertion(+) create mode 100644 bacon.txt ls bacon.txt echo "bits" >> bacon.txt git stash Saved working directory and index state WIP on master: 6d2649a initial commit HEAD is now at 6d2649a initial commit git stash list stash@{0}: WIP on master: 6d2649a initial commit git show stash@{0} commit d152562d7dcbf7ebdf806977cae8308f1e7bb663 Merge: 6d2649a d5b0ce0 Author: John Smith <john.smith@gmail.com> Date: Wed Jul 22 02:26:34 2015 -0700 WIP on master: 6d2649a initial commit diff --cc bacon.txt index 6e953b2,63953b2..b11453f --- a/bacon.txt +++ b/bacon.txt @@@ -1,1 -1,1 +1,2 @@@ bacon ++bits git log --oneline 6d2649a initial commit git branch * master git fsck --lost-found Checking object directories: 100% (256/256), done. git show-ref 6d2649ab6b3f34ecf5437314f08f9b291f8fb9e3 refs/heads/master d152562d7dcbf7ebdf806977cae8308f1e7bb663 refs/stash