Skip to content
Search

Git:Stash

lastmod 2015-03-20created 2014-03-049 edits

Backs up unstaged files in the working directory and returns the working directory to a clean state, i.e. the state of HEAD

Frequently used Git Stash command options

git stash save
Saves the current work and restores to HEAD.
git stash list
Shows the list of saved stashes.
git stash pop
Takes out and applies the most recently saved stash.
git stash apply
Same as stash pop, but does not delete it from the list.
git stash clear
Deletes all stashes.
git stash drop
Deletes an unneeded stash.

Example

A summary of how to use the Stash command.

Checking another Branch

  1. Check the Branch you are currently working on: git branch
    (assume the master branch)
  2. Save the current work: git stash save
  3. Move to another Branch: git checkout 93fd64b
  4. Check the Branch.
    • Check the log and status: git log --oneline --decorate --graph --all
  5. After checking, move back to the Branch you were working on: git checkout master
  6. Restore the previous work: git stash pop