How to move not committed changes to a new branch in Git?


Ever started working on the wrong branch with Git? Use git stash:

# Use stash to detach unstaged changes
git stash
# Change branch
git checkout my-branch
# Retrieve your changes as you left them
git stash pop
# stash can do much more, see its options with:
git stash help