How to use git stash
Here's the sequence to follow when using git stash:
- Save changes to branch A.
- Run
git stash
. - Check out branch B.
- Fix the bug in branch B.
- Commit and (optionally) push to remote.
- Check out branch A
- 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}