How to use git stash ?

How to use git stash

Here's the sequence to follow when using git stash:

  1. Save changes to branch A.
  2. Run git stash.
  3. Check out branch B.
  4. Fix the bug in branch B.
  5. Commit and (optionally) push to remote.
  6. Check out branch A
  7. Run git stash pop to get your stashed changes back.
Listing stashes
  • git stash list --> to see all the stashes
Use any stashed changes

git stash pop stash@{1}

description to git stash
  • git stash save "some kind of description"
Created new branch from a stash

git stash branch test_2 stash@{0}