USING STASH FUNCTION
BASIC USAGE
Stash the change
$ echo "May the force be with you!" >> abc.txt
$ git diff
$ git stash save "Let's stash this change"
$ git diff
Check the stash status
$ git stash list
How to apply the stash?
- Using apply command, make change back to file, but stash still there:
# Most recently change is 0, others +1 $ git stash apply stash@{0} # Change back to previously $ git checkout -- .
- Grab top stash, apply the change, and drop the stash:
$ git stash pop
Remove the stash
- Remove speicify stash:
$ git stash drop stash@{0}
- Remove all the stash:
$ git stash clear
USING STASH TO CHANGE BRANCH
$ git checkout master
$ echo "May the force be with you!" >> abc.txt
$ git status
$ git diff
$ git stash save "Make some change"
$ git checkout 'hello-there'
$ git stash pop
$ git diff
$ git add .
$ git commit -m "Make changes on feature branch"
Reference
Git tutorial published at YouTube by Corey Schafer on Apr 17, 2015.