Lets assume one scenario :
- Currently I'm on Master branch.
- I make a new branch and switch to it.
- I do some new work, but don't make any commits.
What happens when I switch back to master?
- Either My changes come with me to the destination branch.
- Or Git won't let me switch if it detects potential conflicts.
Git Stashing
Git provides an easy way of stashing these uncommitted changes so that we can return to them later, without having to make unnecessary commits.
git stash
git stash pop
git stash is super useful command that helps us save changes that are not yet ready to commit. we can stash changes and then come back to them later. Running git stash will take all uncommitted changes (staged and unstaged) and stash them, reverting the changes in our working copy.
git stash pop to remove the most recently stashed changes in our stash and re-apply them to our working copy.
Git stash apply
git stash apply
git stash -u
git stash
do some other stuff...
git stash
do some other stuff...
git stash
git stash list
git stash apply [stash_id]
git stash drop [stash_id]
git stash clear