Git Stash

We use git stash to store our changes when they are not ready to be committed and we need to change to a different branch.

sh git stash save # or git stash # or with a message git stash save "this is a message to display on the list"

sh git stash apply # or apply a specific one from out stack git stash apply stash@{3}

sh git stash list # or for more information (log methods) git stash list --stat

sh # drop top stash git stash drop # or git stash drop <name> # to clear all history we can use git stash clear

sh git stash pop

Git Stash sample workflow

  1. Modify a file
  2. Stage file
  3. Stash it
  4. View our stash list
  5. Confirm no pending changes through status
  6. Apply with pop
  7. View list to confirm changes
# Modify edit_this_file.rb file
git add .

git stash save "Saving changes from edit this file"

git stash list
git status

git stash pop
git stash list
git status