Stash

A stash is simply a list of patches, that you can apply wherever you want.

  • Take all modified tracked files (that are unstaged) and staged changes, and save them onto a stack of unfinished changes

When you run git stash (alias of git stash save), git makes two commits that are not on any branch.

  1. One commit holds the state of the index,
  2. the second commit holds state of the work tree.

git stash takes uncommitted changes, stores them internally, then runs git reset --hard to give us a clean working directory.

  • This means that stashes can be applied to any branch, useful if we ever discover that we were developing on the wrong branch.

Apply vs Pop

  • pop will delete the stash after it is applied, while apply keeps it around for future use
    • this is why the below trick to revert the stash does not work if pop is used

Children
  1. Cook