git stashing & branching

Just discovered something useful today.

- I am working on something on my “master” branch
- I need to update master with some new stuff from a remote.
- I don’t want to mess up with my current changes

Here is the best way to do it in my opinion (works with git 1.6 and above).

git stash save "some stash name"
git stash branch stash@{0} # assuming you only have one stash, otherwise git stash list to know the exact index

You changes should end up in the new branch and you can checkout your master branch to get the new changes from the remote repository.